Update Prisma dependencies and refactor host onboarding handlers
- Updated Prisma client and adapter versions in package.json and package-lock.json. - Refactored host onboarding handlers to improve structure and naming conventions. - Added new handlers for onboarding processes including login, signup, and OTP verification. - Implemented new functionality for managing bank details and company submissions. - Enhanced error handling and validation across various handlers.
This commit is contained in:
2194
package-lock.json
generated
2194
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -40,7 +40,8 @@
|
||||
"@nestjs/platform-express": "^10.3.0",
|
||||
"@nestjs/swagger": "^7.1.17",
|
||||
"@nestjs/throttler": "^5.1.1",
|
||||
"@prisma/client": "^7.0.0",
|
||||
"@prisma/adapter-pg": "^7.0.1",
|
||||
"@prisma/client": "^7.0.1",
|
||||
"@smithy/middleware-stack": "^4.2.5",
|
||||
"@smithy/protocol-http": "^5.3.5",
|
||||
"@smithy/types": "^4.9.0",
|
||||
@@ -59,7 +60,7 @@
|
||||
"passport": "^0.7.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"passport-local": "^1.0.0",
|
||||
"prisma": "^7.0.0",
|
||||
"prisma": "^7.0.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rxjs": "^7.8.1",
|
||||
"serverless": "4.17.0",
|
||||
|
||||
@@ -17,8 +17,8 @@ getHosts:
|
||||
path: /host
|
||||
method: get
|
||||
|
||||
verifyOtp:
|
||||
handler: src/modules/host/handlers/verifyOtp.handler
|
||||
verifyOTP:
|
||||
handler: src/modules/host/handlers/Host_Admin/onboarding/verifyOTP.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -33,8 +33,8 @@ verifyOtp:
|
||||
path: /host/verify-otp
|
||||
method: post
|
||||
|
||||
loginForHost:
|
||||
handler: src/modules/host/handlers/loginForHost.handler
|
||||
login:
|
||||
handler: src/modules/host/handlers/Host_Admin/onboarding/login.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -49,8 +49,8 @@ loginForHost:
|
||||
path: /host/login
|
||||
method: post
|
||||
|
||||
registrationOfHost:
|
||||
handler: src/modules/host/handlers/registration.handler
|
||||
signUp:
|
||||
handler: src/modules/host/handlers/Host_Admin/onboarding/signUp.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -65,8 +65,8 @@ registrationOfHost:
|
||||
path: /host/registration
|
||||
method: post
|
||||
|
||||
createPasswordForHost:
|
||||
handler: src/modules/host/handlers/createPassword.handler
|
||||
createPassword:
|
||||
handler: src/modules/host/handlers/Host_Admin/onboarding/createPassword.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -81,8 +81,8 @@ createPasswordForHost:
|
||||
path: /host/create-password
|
||||
method: post
|
||||
|
||||
addPaymentDetailsForHost:
|
||||
handler: src/modules/host/handlers/addPaymentDetails.handler
|
||||
updateBankDetails:
|
||||
handler: src/modules/host/handlers/Host_Admin/onboarding/updateBankDetails.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -97,8 +97,8 @@ addPaymentDetailsForHost:
|
||||
path: /host/add-payment-details
|
||||
method: post
|
||||
|
||||
addActivity:
|
||||
handler: src/modules/host/handlers/addActivity.handler
|
||||
saveActivity_ForPQQ:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/saveActivity_ForPQQ.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -129,8 +129,8 @@ getHostById:
|
||||
path: /host/getById
|
||||
method: get
|
||||
|
||||
getPQQQuestionDetailsById:
|
||||
handler: src/modules/host/handlers/getByIdPQQ.handler
|
||||
getPQQ_ByQuestionId:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/getPQQ_ByQuestionId.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -145,8 +145,8 @@ getPQQQuestionDetailsById:
|
||||
path: /host/get-pqq-question-details
|
||||
method: get
|
||||
|
||||
getLatestPQQQuestionDetails:
|
||||
handler: src/modules/host/handlers/getLatestQuestionDetailsPQQ.handler
|
||||
getPQQ_LastUpdatedQuestion:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/getPQQ_LastUpdatedQuestion.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -161,8 +161,8 @@ getLatestPQQQuestionDetails:
|
||||
path: /host/get-latest-pqq-question-details
|
||||
method: get
|
||||
|
||||
getActivityTypes:
|
||||
handler: src/modules/host/handlers/getActivity.handler
|
||||
getAllActivity:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/getAllActivity.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -177,8 +177,8 @@ getActivityTypes:
|
||||
path: /host/get-activity
|
||||
method: get
|
||||
|
||||
acceptMinglarAgreement:
|
||||
handler: src/modules/host/handlers/acceptAgreement.handler
|
||||
acceptAggrement:
|
||||
handler: src/modules/host/handlers/Host_Admin/onboarding/acceptAggrement.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -212,8 +212,8 @@ getStepperInfo:
|
||||
method: get
|
||||
|
||||
# Functions with S3/AWS SDK dependencies
|
||||
addCompanyDetails:
|
||||
handler: src/modules/host/handlers/addCompanyDetails.handler
|
||||
submitCompanyDetails:
|
||||
handler: src/modules/host/handlers/Host_Admin/onboarding/submitCompanyDetails.handler
|
||||
memorySize: 512
|
||||
timeout: 30
|
||||
package:
|
||||
@@ -246,8 +246,8 @@ addCompanyDetails:
|
||||
path: /host/add-company-details
|
||||
method: post
|
||||
|
||||
submitPqqAnswer:
|
||||
handler: src/modules/host/handlers/submitPqqAns.handler
|
||||
submitPQQ_Answer:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/submitPQQ_Answer.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
@@ -262,8 +262,8 @@ submitPqqAnswer:
|
||||
path: /host/submit-pqq-answer
|
||||
method: post
|
||||
|
||||
submitFinalPqqAnswer:
|
||||
handler: src/modules/host/handlers/submitPqqAns.handler
|
||||
updatePQQ_LastAnswer:
|
||||
handler: src/modules/host/handlers/Activity_Hub/OnBoarding/updatePQQ_Answer.handler
|
||||
memorySize: 384
|
||||
package:
|
||||
patterns:
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { Injectable, OnModuleInit, OnModuleDestroy, INestApplication } from '@nestjs/common';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
|
||||
@Injectable()
|
||||
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
||||
constructor() {
|
||||
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
|
||||
super({
|
||||
adapter,
|
||||
log: process.env.NODE_ENV === 'dev' ? ['query', 'info', 'warn', 'error'] : ['error'],
|
||||
});
|
||||
}
|
||||
@@ -22,5 +25,4 @@ export class PrismaService extends PrismaClient implements OnModuleInit, OnModul
|
||||
await app.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
@@ -1,9 +1,9 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '../../../common/middlewares/jwt/authForHost';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { verifyMinglarAdminHostToken } from '@/common/middlewares/jwt/authForMinglarAdmin&Host';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
@@ -1,9 +1,9 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '../../../common/middlewares/jwt/authForHost';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
@@ -1,9 +1,9 @@
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
@@ -3,11 +3,11 @@ import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
|
||||
import AWS from 'aws-sdk';
|
||||
import Busboy from 'busboy';
|
||||
import crypto from 'crypto';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { verifyHostToken } from '../../../common/middlewares/jwt/authForHost';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
|
||||
const prisma = new PrismaService();
|
||||
const pqqService = new HostService(prisma);
|
||||
@@ -1,9 +1,9 @@
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
@@ -1,9 +1,9 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { HostService } from '../services/host.service';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '../../../common/middlewares/jwt/authForHost';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
@@ -1,15 +1,15 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { TokenService } from '../services/token.service';
|
||||
import { GetHostLoginResponseDTO } from '../dto/host.dto';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { TokenService } from '../../../services/token.service';
|
||||
import { GetHostLoginResponseDTO } from '../../../dto/host.dto';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
const tokenService = new TokenService();
|
||||
const tokenService = new TokenService(prismaService);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
@@ -1,8 +1,8 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { MinglarService } from '../../minglaradmin/services/minglar.service';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { MinglarService } from '../../../../minglaradmin/services/minglar.service';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
@@ -1,13 +1,13 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { OtpGeneratorSixDigit } from '../../../common/utils/helper/OtpGenerator';
|
||||
import { encryptUserId } from '../../../common/utils/helper/CodeGenerator';
|
||||
import { HostService } from '../services/host.service';
|
||||
import { sendOtpEmailForHost } from '../services/sendOTPEmail.service';
|
||||
import { ROLE } from '../../../common/utils/constants/common.constant';
|
||||
import { OtpGeneratorSixDigit } from '../../../../../common/utils/helper/OtpGenerator';
|
||||
import { encryptUserId } from '../../../../../common/utils/helper/CodeGenerator';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { sendOtpEmailForHost } from '../../../services/sendOTPEmail.service';
|
||||
import { ROLE } from '../../../../../common/utils/constants/common.constant';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
@@ -3,18 +3,18 @@ import config from '@/config/config';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
|
||||
import AWS from 'aws-sdk';
|
||||
import Busboy from 'busboy';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { verifyHostToken } from '../../../common/middlewares/jwt/authForHost';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import {
|
||||
hostCompanyDetailsSchema,
|
||||
hostDocumentsSchema,
|
||||
parentCompanySchema,
|
||||
REQUIRED_DOC_TYPES
|
||||
} from '../../../common/utils/validation/host/hostCompanyDetails.validation';
|
||||
import { HostService } from '../../host/services/host.service';
|
||||
import { sendEmailToAM, sendEmailToMinglarAdmin } from '../services/sendHostResubmitEmailToAM.service';
|
||||
} from '../../../../../common/utils/validation/host/hostCompanyDetails.validation';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { sendEmailToAM, sendEmailToMinglarAdmin } from '../../../services/sendHostResubmitEmailToAM.service';
|
||||
|
||||
const prisma = new PrismaService();
|
||||
const hostService = new HostService(prisma);
|
||||
@@ -1,8 +1,8 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { HostService } from '../services/host.service';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { verifyHostToken } from '@/common/middlewares/jwt/authForHost';
|
||||
import { hostBankDetailsSchema } from '@/common/utils/validation/host/addPaymentDetails.validation';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { HostService } from '../services/host.service';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { TokenService } from '../services/token.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { TokenService } from '../../../services/token.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
const tokenService = new TokenService();
|
||||
const tokenService = new TokenService(prismaService);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
@@ -1,11 +1,11 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaService } from "../../../common/database/prisma.service";
|
||||
import jwt, { JwtPayload } from "jsonwebtoken";
|
||||
import moment from "moment";
|
||||
import config from "../../../config/config";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export class TokenService {
|
||||
constructor(private readonly prisma: PrismaService = new PrismaService()) {}
|
||||
|
||||
private generateToken(
|
||||
user_xid: number,
|
||||
expiresIn: Date,
|
||||
@@ -53,7 +53,7 @@ export class TokenService {
|
||||
config.jwt.secret
|
||||
);
|
||||
|
||||
await prisma.token.create({
|
||||
await this.prisma.token.create({
|
||||
data: {
|
||||
token: refreshToken.token,
|
||||
expiringAt: refreshToken.expires,
|
||||
@@ -100,7 +100,7 @@ export class TokenService {
|
||||
config.jwt.secret
|
||||
);
|
||||
|
||||
await prisma.token.create({
|
||||
await this.prisma.token.create({
|
||||
data: {
|
||||
token: refreshToken.token,
|
||||
expiringAt: refreshToken.expires,
|
||||
@@ -119,7 +119,7 @@ export class TokenService {
|
||||
}
|
||||
|
||||
async revokeToken(user_xid: number, deviceId: string): Promise<boolean> {
|
||||
const existingToken = await prisma.token.findFirst({
|
||||
const existingToken = await this.prisma.token.findFirst({
|
||||
where: {
|
||||
id: user_xid,
|
||||
deviceId,
|
||||
@@ -128,12 +128,12 @@ export class TokenService {
|
||||
|
||||
if (!existingToken) return false;
|
||||
|
||||
await prisma.token.delete({ where: { id: existingToken.id } });
|
||||
await this.prisma.token.delete({ where: { id: existingToken.id } });
|
||||
return true;
|
||||
}
|
||||
|
||||
async isTokenBlackListed(token: string): Promise<boolean> {
|
||||
const existing = await prisma.token.findUnique({
|
||||
const existing = await this.prisma.token.findUnique({
|
||||
where: { token },
|
||||
});
|
||||
return existing ? true : false;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { TokenService } from "../services/token.service";
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarSerivce = new MinglarService(prismaService);
|
||||
const tokenService = new TokenService();
|
||||
const tokenService = new TokenService(prismaService);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaService } from "../../../common/database/prisma.service";
|
||||
import jwt, { JwtPayload } from "jsonwebtoken";
|
||||
import moment from "moment";
|
||||
import config from "../../../config/config";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export class TokenService {
|
||||
constructor(private readonly prisma: PrismaService = new PrismaService()) {}
|
||||
|
||||
private generateToken(
|
||||
user_xid: number,
|
||||
expiresIn: Date,
|
||||
@@ -53,7 +53,7 @@ export class TokenService {
|
||||
config.jwt.secret
|
||||
);
|
||||
|
||||
await prisma.token.create({
|
||||
await this.prisma.token.create({
|
||||
data: {
|
||||
token: refreshToken.token,
|
||||
expiringAt: refreshToken.expires,
|
||||
@@ -100,7 +100,7 @@ export class TokenService {
|
||||
config.jwt.secret
|
||||
);
|
||||
|
||||
await prisma.token.create({
|
||||
await this.prisma.token.create({
|
||||
data: {
|
||||
token: refreshToken.token,
|
||||
expiringAt: refreshToken.expires,
|
||||
@@ -119,7 +119,7 @@ export class TokenService {
|
||||
}
|
||||
|
||||
async revokeToken(user_xid: number, deviceId: string): Promise<boolean> {
|
||||
const existingToken = await prisma.token.findFirst({
|
||||
const existingToken = await this.prisma.token.findFirst({
|
||||
where: {
|
||||
id: user_xid,
|
||||
deviceId,
|
||||
@@ -128,12 +128,12 @@ export class TokenService {
|
||||
|
||||
if (!existingToken) return false;
|
||||
|
||||
await prisma.token.delete({ where: { id: existingToken.id } });
|
||||
await this.prisma.token.delete({ where: { id: existingToken.id } });
|
||||
return true;
|
||||
}
|
||||
|
||||
async isTokenBlackListed(token: string): Promise<boolean> {
|
||||
const existing = await prisma.token.findUnique({
|
||||
const existing = await this.prisma.token.findUnique({
|
||||
where: { token },
|
||||
});
|
||||
return existing ? true : false;
|
||||
|
||||
Reference in New Issue
Block a user