Refactor database access by introducing prisma.lambda.service for centralized PrismaClient usage across modules. Update imports in various handlers and services to utilize the new service, ensuring consistent database interactions and improved maintainability.
This commit is contained in:
22
src/common/database/prisma.lambda.service.ts
Normal file
22
src/common/database/prisma.lambda.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
|
||||
const adapter = new PrismaPg({
|
||||
connectionString: process.env.DATABASE_URL!,
|
||||
});
|
||||
|
||||
let prisma: PrismaClient;
|
||||
|
||||
if (!(global as any).prisma) {
|
||||
(global as any).prisma = new PrismaClient({
|
||||
adapter,
|
||||
log:
|
||||
process.env.NODE_ENV === 'dev'
|
||||
? ['query', 'info', 'warn', 'error']
|
||||
: ['error'],
|
||||
});
|
||||
}
|
||||
|
||||
prisma = (global as any).prisma;
|
||||
|
||||
export const prismaClient = prisma;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { PrismaService } from './prisma.service';
|
||||
import { PrismaService } from './prisma.lambda.service';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import { Injectable, OnModuleInit, OnModuleDestroy, INestApplication } from '@nestjs/common';
|
||||
import { Injectable, OnModuleInit, OnModuleDestroy } 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'],
|
||||
});
|
||||
}
|
||||
|
||||
async onModuleInit() {
|
||||
await this.$connect();
|
||||
}
|
||||
@@ -19,10 +10,4 @@ export class PrismaService extends PrismaClient implements OnModuleInit, OnModul
|
||||
async onModuleDestroy() {
|
||||
await this.$disconnect();
|
||||
}
|
||||
|
||||
async enableShutdownHooks(app: INestApplication) {
|
||||
process.on('beforeExit', async () => {
|
||||
await app.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,12 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(
|
||||
async (
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { PrePopulateService } from '../../../../prepopulate/services/prepopulate.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const hostService = new HostService(prismaClient);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
/**
|
||||
* Add suggestion handler for host applications
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { paginationService } from '../../../../../common/utils/pagination/pagination.service';
|
||||
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { verifyMinglarAdminHostToken } from '../../../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -3,14 +3,13 @@ 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 { prismaClient } from '../../../../../common/database/prisma.lambda.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 hostService = new HostService(prisma);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
const s3 = new AWS.S3({ region: config.aws.region });
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyMinglarAdminHostToken } from '../../../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
context?: Context
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
context?: Context
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -3,14 +3,13 @@ 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 { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
|
||||
const prisma = new PrismaService();
|
||||
const hostService = new HostService(prisma);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
const s3 = new AWS.S3({ region: config.aws.region });
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
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);
|
||||
const pqqService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {
|
||||
try {
|
||||
|
||||
@@ -3,14 +3,13 @@ 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 { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const pqqService = new HostService(prismaClient);
|
||||
|
||||
const s3 = new AWS.S3({ region: config.aws.region });
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
/**
|
||||
* Add suggestion handler for host applications
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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(prismaService);
|
||||
const hostService = new HostService(prismaClient);
|
||||
const tokenService = new TokenService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
@@ -42,7 +40,7 @@ export const handler = safeHandler(async (
|
||||
|
||||
const generateTokenForHost = await tokenService.generateAuthToken(
|
||||
loginForHost.id
|
||||
);
|
||||
);
|
||||
|
||||
if (!generateTokenForHost) {
|
||||
throw new ApiError(500, 'Failed to generate token');
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
/**
|
||||
* Get suggestions handler
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { ROLE } from '../../../../../common/utils/constants/common.constant';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
@@ -8,8 +8,7 @@ import { encryptUserId } from '../../../../../common/utils/helper/CodeGenerator'
|
||||
import { OtpGeneratorSixDigit } from '../../../../../common/utils/helper/OtpGenerator';
|
||||
import { HostService } from '../../../services/host.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export async function generateHostRefNumber(tx: any) {
|
||||
const lastrecord = await tx.user.findFirst({
|
||||
@@ -46,7 +45,7 @@ export const handler = safeHandler(async (
|
||||
}
|
||||
|
||||
// Use a single transaction for user creation/lookup and OTP storage
|
||||
const transactionResult = await prismaService.$transaction(async (tx) => {
|
||||
const transactionResult = await prismaClient.$transaction(async (tx) => {
|
||||
const user = await tx.user.findUnique({
|
||||
where: { emailAddress: email },
|
||||
select: { emailAddress: true, id: true, userPassword: true },
|
||||
|
||||
@@ -3,7 +3,7 @@ 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 { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
@@ -15,8 +15,7 @@ import {
|
||||
import { HostService } from '../../../services/host.service';
|
||||
import { sendEmailToAM, sendEmailToMinglarAdmin } from '../../../services/sendHostResubmitEmailToAM.service';
|
||||
|
||||
const prisma = new PrismaService();
|
||||
const hostService = new HostService(prisma);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
const s3 = new AWS.S3({
|
||||
region: config.aws.region,
|
||||
@@ -156,7 +155,7 @@ export const handler = safeHandler(async (event: APIGatewayProxyEvent): Promise<
|
||||
if (userProfileRaw) {
|
||||
const { firstName, lastName, mobileNumber } = userProfileRaw;
|
||||
|
||||
await prisma.user.update({
|
||||
await prismaClient.user.update({
|
||||
where: { id: userInfo.id },
|
||||
data: {
|
||||
...(firstName && { firstName }),
|
||||
@@ -250,7 +249,7 @@ export const handler = safeHandler(async (event: APIGatewayProxyEvent): Promise<
|
||||
await deleteFromS3(s3Key);
|
||||
|
||||
// Delete from DB
|
||||
await prisma.hostDocuments.delete({
|
||||
await prismaClient.hostDocuments.delete({
|
||||
where: { id }
|
||||
});
|
||||
|
||||
@@ -277,7 +276,7 @@ export const handler = safeHandler(async (event: APIGatewayProxyEvent): Promise<
|
||||
await deleteFromS3(s3Key);
|
||||
|
||||
// Delete DB
|
||||
await prisma.hostParenetDocuments.delete({
|
||||
await prismaClient.hostParenetDocuments.delete({
|
||||
where: { id }
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.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(prismaService);
|
||||
const hostService = new HostService(prismaClient);
|
||||
const tokenService = new TokenService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
context?: Context
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyMinglarAdminHostToken } from '../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.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);
|
||||
const hostService = new HostService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
@@ -14,7 +13,7 @@ export const handler = safeHandler(async (
|
||||
): Promise<APIGatewayProxyResult> => {
|
||||
// Get host ID from path parameters
|
||||
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token']
|
||||
if(!token) {
|
||||
if (!token) {
|
||||
throw new ApiError(400, 'This is a protected route. Please provide a valid token.');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const prisma = prismaClient;
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent
|
||||
@@ -11,7 +11,6 @@ export const handler = safeHandler(async (
|
||||
const result = await prisma.hostHeader.findMany({
|
||||
select: {
|
||||
hostParent: true,
|
||||
hostRefNumber: true,
|
||||
hostStatusDisplay: true,
|
||||
accountManager: true,
|
||||
},
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
|
||||
import { PrismaService } from "../../../common/database/prisma.service";
|
||||
import { prismaClient } from "../../../common/database/prisma.lambda.service";
|
||||
import { safeHandler } from "../../../common/utils/handlers/safeHandler";
|
||||
import ApiError from "../../../common/utils/helper/ApiError";
|
||||
import { resendOtpHelper } from "../../../common/utils/helper/resendOtpHelper";
|
||||
import { resendOtpEmail } from "../services/resendOTPEmail.service";
|
||||
|
||||
const prisma = new PrismaService();
|
||||
const prisma = prismaClient;
|
||||
|
||||
// allowed purposes
|
||||
const ALLOWED_PURPOSES = ["Register", "Login", "ForgotPassword"] as const;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// src/modules/host/services/host.service.ts
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import {
|
||||
AddPaymentDetailsDTO,
|
||||
CreateHostDto,
|
||||
@@ -9,28 +8,29 @@ import {
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { User } from '@prisma/client';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { z } from 'zod';
|
||||
import { hostCompanyDetailsSchema } from '@/common/utils/validation/host/hostCompanyDetails.validation';
|
||||
import { hostCompanyDetailsSchema } from '../../../common/utils/validation/host/hostCompanyDetails.validation';
|
||||
import {
|
||||
ACTIVITY_AM_DISPLAY_STATUS,
|
||||
ACTIVITY_AM_INTERNAL_STATUS,
|
||||
ACTIVITY_DISPLAY_STATUS, ACTIVITY_INTERNAL_STATUS, HOST_STATUS_DISPLAY,
|
||||
HOST_STATUS_INTERNAL,
|
||||
STEPPER,
|
||||
} from '@/common/utils/constants/host.constant';
|
||||
} from '../../../common/utils/constants/host.constant';
|
||||
import {
|
||||
ACTIVITY_TRACK_STATUS,
|
||||
ACTIVITY_TRACK_TYPE,
|
||||
MINGLAR_STATUS_DISPLAY,
|
||||
MINGLAR_STATUS_INTERNAL,
|
||||
} from '@/common/utils/constants/minglar.constant';
|
||||
} from '../../../common/utils/constants/minglar.constant';
|
||||
import {
|
||||
ROLE,
|
||||
ROLE_NAME,
|
||||
USER_STATUS,
|
||||
} from '@/common/utils/constants/common.constant';
|
||||
import { getPresignedUrl } from '@/common/middlewares/aws/getPreSignedUrl';
|
||||
import config from '@/config/config';
|
||||
} from '../../../common/utils/constants/common.constant';
|
||||
import { getPresignedUrl } from '../../../common/middlewares/aws/getPreSignedUrl';
|
||||
import config from '../../../config/config';
|
||||
|
||||
type HostCompanyDetailsInput = z.infer<typeof hostCompanyDetailsSchema>;
|
||||
|
||||
@@ -63,7 +63,7 @@ const bucket = config.aws.bucketName;
|
||||
|
||||
@Injectable()
|
||||
export class HostService {
|
||||
constructor(private prisma: PrismaService) { }
|
||||
constructor(private prisma: PrismaClient) { }
|
||||
|
||||
async createHost(data: CreateHostDto) {
|
||||
return this.prisma.user.create({ data });
|
||||
@@ -298,6 +298,7 @@ export class HostService {
|
||||
userStatus: true
|
||||
}
|
||||
});
|
||||
console.log(existingUser, "ajsbfkjd")
|
||||
|
||||
if (!existingUser) {
|
||||
throw new ApiError(404, 'User not found');
|
||||
@@ -1786,6 +1787,7 @@ export class HostService {
|
||||
isActive: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
comments: true,
|
||||
pqqAnswerXid: true,
|
||||
pqqQuestions: {
|
||||
@@ -1851,15 +1853,20 @@ export class HostService {
|
||||
const sub = q.pqqSubCategories;
|
||||
const cat = sub.category;
|
||||
|
||||
// 1️⃣ Category level
|
||||
// 1️⃣ Category level
|
||||
if (!grouped[cat.id]) {
|
||||
grouped[cat.id] = {
|
||||
id: cat.id,
|
||||
categoryName: cat.categoryName,
|
||||
displayOrder: cat.displayOrder,
|
||||
activityPqqHeaderId: item.id, // ✅ Added to match AM response
|
||||
pqqsubCategories: []
|
||||
};
|
||||
} else if (!grouped[cat.id].activityPqqHeaderId) {
|
||||
grouped[cat.id].activityPqqHeaderId = item.id; // Ensures it's set if missing
|
||||
}
|
||||
|
||||
const category = grouped[cat.id];
|
||||
|
||||
// 2️⃣ Subcategory level
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { PrismaService } from "../../../common/database/prisma.service";
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import jwt, { JwtPayload } from "jsonwebtoken";
|
||||
import moment from "moment";
|
||||
import config from "../../../config/config";
|
||||
|
||||
export class TokenService {
|
||||
constructor(private readonly prisma: PrismaService = new PrismaService()) {}
|
||||
constructor(private prisma: PrismaClient) { }
|
||||
|
||||
private generateToken(
|
||||
user_xid: number,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyMinglarAdminToken } from '../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -3,14 +3,13 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
/**
|
||||
* Get all host applications handler
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { sendEmailToHostForApprovedApplication } from '../../../services/approvalMailtoHost.service';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface AddSuggestionBody {
|
||||
hostXid: number;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface Body {
|
||||
activityId: number;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
// import { HOST_SUGGESTION_TITLES } from '../../../../../common/utils/constants/minglar.constant';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface AddSuggestionBody {
|
||||
title: string;
|
||||
@@ -34,7 +33,7 @@ export const handler = safeHandler(async (
|
||||
const userInfo = await verifyMinglarAdminToken(token);
|
||||
|
||||
// Get user details
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { id: userInfo.id },
|
||||
select: { id: true, roleXid: true }
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface AddSuggestionBody {
|
||||
hostXid: number;
|
||||
@@ -34,7 +33,7 @@ export const handler = safeHandler(async (
|
||||
const userInfo = await verifyMinglarAdminToken(token);
|
||||
|
||||
// Get user details
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { id: userInfo.id },
|
||||
select: { id: true, roleXid: true }
|
||||
});
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { paginationService } from '../../../../../common/utils/pagination/pagination.service';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
/**
|
||||
* Get all host applications handler with pagination
|
||||
@@ -26,7 +25,7 @@ export const handler = safeHandler(async (
|
||||
const userInfo = await verifyMinglarAdminToken(token);
|
||||
|
||||
// Get user details including role
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { id: userInfo.id },
|
||||
select: { id: true, roleXid: true }
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import { sendAMRejectionMailtoHost } from '../../../services/rejectionMailtoHost.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface AddSuggestionBody {
|
||||
hostXid: number;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface Body {
|
||||
activityId: number;
|
||||
|
||||
@@ -3,14 +3,13 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyOnlyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForOnlyMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface assignAMToHostBody {
|
||||
host_xid: number;
|
||||
@@ -40,7 +39,7 @@ export const handler = safeHandler(
|
||||
const userInfo = await verifyOnlyMinglarAdminToken(token);
|
||||
|
||||
// Get user details including role
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { id: userInfo.id },
|
||||
select: { id: true, roleXid: true },
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyOnlyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForOnlyMinglarAdmin';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface assignAMToHostBody {
|
||||
host_xid: number,
|
||||
@@ -34,7 +33,7 @@ export const handler = safeHandler(async (
|
||||
const userInfo = await verifyOnlyMinglarAdminToken(token);
|
||||
|
||||
// Get user details including role
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { id: userInfo.id },
|
||||
select: { id: true, roleXid: true }
|
||||
});
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { PrePopulateService } from '../../../../prepopulate/services/prepopulate.service';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import { paginationService } from '../../../../../common/utils/pagination/pagination.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
/**
|
||||
* Add suggestion handler for host applications
|
||||
|
||||
@@ -4,14 +4,13 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { paginationService } from '../../../../../common/utils/pagination/pagination.service';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
/**
|
||||
* Get all host applications handler
|
||||
@@ -36,7 +35,7 @@ export const handler = safeHandler(
|
||||
const userInfo = await verifyOnlyMinglarAdminToken(token);
|
||||
|
||||
// Get user details including role
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { id: userInfo.id },
|
||||
select: { id: true, roleXid: true },
|
||||
});
|
||||
|
||||
@@ -3,15 +3,14 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyOnlyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForOnlyMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { paginationService } from '../../../../../common/utils/pagination/pagination.service';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
/**
|
||||
* Get all NEW host applications handler
|
||||
@@ -36,7 +35,7 @@ export const handler = safeHandler(
|
||||
const userInfo = await verifyOnlyMinglarAdminToken(token);
|
||||
|
||||
// Get user details including role
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { id: userInfo.id },
|
||||
select: { id: true, roleXid: true },
|
||||
});
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { verifyOnlyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForOnlyMinglarAdmin';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import { sendEmailToHostForRejectedApplication } from '../../../services/rejectionMailtoHost.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface AddSuggestionBody {
|
||||
hostXid: number;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import { verifyMinglarAdminHostToken } from '../../../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { GetMinglarLoginResponseDTO } from '../dto/minglar.dto';
|
||||
import { MinglarService } from '../services/minglar.service';
|
||||
import { TokenService } from "../services/token.service";
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarSerivce = new MinglarService(prismaService);
|
||||
const tokenService = new TokenService(prismaService);
|
||||
const minglarSerivce = new MinglarService(prismaClient);
|
||||
const tokenService = new TokenService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -3,13 +3,13 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { ROLE } from '../../../common/utils/constants/common.constant';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prismaService = prismaClient;
|
||||
export const handler = safeHandler(
|
||||
async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { ROLE, USER_STATUS } from '../../../common/utils/constants/common.constant';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { generateOtpHelper } from '../../../common/utils/helper/sendOtp';
|
||||
import { MinglarService } from './../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
@@ -28,7 +27,7 @@ export const handler = safeHandler(async (
|
||||
throw new ApiError(400, 'Email is required');
|
||||
}
|
||||
|
||||
const user = await prismaService.user.findUnique({
|
||||
const user = await prismaClient.user.findUnique({
|
||||
where: { emailAddress: email, isActive: true, userStatus: USER_STATUS.INVITED },
|
||||
select: { emailAddress: true, id: true, userPassword: true, roleXid: true },
|
||||
});
|
||||
@@ -54,7 +53,7 @@ export const handler = safeHandler(async (
|
||||
}
|
||||
|
||||
const otpResult = await generateOtpHelper(
|
||||
prismaService, // ⭐ pass Prisma from here
|
||||
prismaClient, // ⭐ pass Prisma from here
|
||||
Number(newUser?.id),
|
||||
newUser?.emailAddress,
|
||||
'Register',
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyOnlyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForOnlyMinglarAdmin';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -4,14 +4,13 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import { paginationService } from '../../../../../common/utils/pagination/pagination.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(
|
||||
async (
|
||||
|
||||
@@ -4,14 +4,13 @@ import {
|
||||
APIGatewayProxyResult,
|
||||
Context,
|
||||
} from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import { paginationService } from '../../../../../common/utils/pagination/pagination.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(
|
||||
async (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { verifyOnlyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForOnlyMinglarAdmin';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../../../common/database/prisma.lambda.service';
|
||||
import { ROLE } from '../../../../../common/utils/constants/common.constant';
|
||||
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../../../common/utils/helper/ApiError';
|
||||
@@ -8,8 +8,7 @@ import { sendInvitationEmailForMinglarAdmin } from '../../../services/inviteTeam
|
||||
import { MinglarService } from '../../../services/minglar.service';
|
||||
import config from '../../../../../config/config';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
interface InviteTeammateBody {
|
||||
emailAddress: string;
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
import config from '../../../config/config';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import AWS from 'aws-sdk';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminToken } from '../../../common/middlewares/jwt/authForMinglarAdmin';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { parseJsonField, parseMultipartFormData } from '../../../common/utils/helper/parseMultipartFormData';
|
||||
import { MinglarService } from '../services/minglar.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const minglarService = new MinglarService(prismaService);
|
||||
const minglarService = new MinglarService(prismaClient);
|
||||
|
||||
const s3 = new AWS.S3({
|
||||
region: config.aws.region,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { PrismaService } from '../../../common/database/prisma.lambda.service';
|
||||
import { sendAMEmailForHostAssign } from './AMEmail.service';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -26,6 +26,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import { User } from '@prisma/client';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { CreateMinglarDto, UpdateMinglarDto } from '../dto/minglar.dto';
|
||||
import { sendAMEmailForHostAssign } from './AMEmail.service';
|
||||
@@ -34,7 +35,7 @@ const bucket = config.aws.bucketName;
|
||||
|
||||
@Injectable()
|
||||
export class MinglarService {
|
||||
constructor(private prisma: PrismaService) { }
|
||||
constructor(private prisma: PrismaService | PrismaClient) { }
|
||||
|
||||
async createPassword(user_xid: number, password: string): Promise<boolean> {
|
||||
// Find user by id
|
||||
@@ -261,7 +262,6 @@ export class MinglarService {
|
||||
const whereClause: any = {
|
||||
isActive: true,
|
||||
activityInternalStatus: { notIn: [ACTIVITY_INTERNAL_STATUS.DRAFT_PQ] },
|
||||
activityInternalStatus: { notIn: [ACTIVITY_INTERNAL_STATUS.DRAFT_PQ] },
|
||||
...(hostXid ? { hostXid } : {}),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { PrismaService } from "../../../common/database/prisma.service";
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import jwt, { JwtPayload } from "jsonwebtoken";
|
||||
import moment from "moment";
|
||||
import config from "../../../config/config";
|
||||
|
||||
export class TokenService {
|
||||
constructor(private readonly prisma: PrismaService = new PrismaService()) {}
|
||||
constructor(private prisma: PrismaClient) { }
|
||||
|
||||
private generateToken(
|
||||
user_xid: number,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { verifyMinglarAdminHostToken } from '../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { PrePopulateService } from '../services/prepopulate.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminHostToken } from '../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { PrePopulateService } from '../services/prepopulate.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminHostToken } from '../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { PrePopulateService } from '../services/prepopulate.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
import { prismaClient } from '../../../common/database/prisma.lambda.service';
|
||||
import { verifyMinglarAdminHostToken } from '../../../common/middlewares/jwt/authForMinglarAdminHost';
|
||||
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
|
||||
import ApiError from '../../../common/utils/helper/ApiError';
|
||||
import { PrePopulateService } from '../services/prepopulate.service';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from "aws-lambda";
|
||||
import { PrismaService } from "../../../common/database/prisma.service";
|
||||
import { prismaClient } from "../../../common/database/prisma.lambda.service";
|
||||
import { verifyMinglarAdminHostToken } from "../../../common/middlewares/jwt/authForMinglarAdminHost";
|
||||
import { safeHandler } from "../../../common/utils/handlers/safeHandler";
|
||||
import ApiError from "../../../common/utils/helper/ApiError";
|
||||
import { PrePopulateService } from "../services/prepopulate.service";
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from "aws-lambda";
|
||||
import { PrismaService } from "../../../common/database/prisma.service";
|
||||
import { prismaClient } from "../../../common/database/prisma.lambda.service";
|
||||
import { verifyMinglarAdminHostToken } from "../../../common/middlewares/jwt/authForMinglarAdminHost";
|
||||
import { safeHandler } from "../../../common/utils/handlers/safeHandler";
|
||||
import ApiError from "../../../common/utils/helper/ApiError";
|
||||
import { PrePopulateService } from "../services/prepopulate.service";
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const prePopulateService = new PrePopulateService(prismaService);
|
||||
const prePopulateService = new PrePopulateService(prismaClient);
|
||||
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '../../../common/database/prisma.service';
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
@Injectable()
|
||||
export class PrePopulateService {
|
||||
constructor(private prisma: PrismaService) { }
|
||||
constructor(private prisma: PrismaClient) { }
|
||||
|
||||
async getAllBankDetails() {
|
||||
return await this.prisma.banks.findMany({
|
||||
|
||||
Reference in New Issue
Block a user