Files
MinglarBackendNestJS/src/modules/minglaradmin/handlers/hosthub/hosts/rejectPQQbyAM.ts

44 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-11-27 19:47:04 +05:30
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
import { PrismaService } from '../../../../../common/database/prisma.service';
import { verifyMinglarAdminToken } from '../../../../../common/middlewares/jwt/authForMinglarAdmin';
2025-11-27 19:47:04 +05:30
import { safeHandler } from '../../../../../common/utils/handlers/safeHandler';
import ApiError from '../../../../../common/utils/helper/ApiError';
import { MinglarService } from '../../../services/minglar.service';
2025-11-27 19:47:04 +05:30
const prismaService = new PrismaService();
const minglarService = new MinglarService(prismaService);
export const handler = safeHandler(async (
event: APIGatewayProxyEvent,
context?: Context
): Promise<APIGatewayProxyResult> => {
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token'];
if (!token) throw new ApiError(401, 'This is a protected route. Please provide a valid token.');
const userInfo = await verifyMinglarAdminToken(token);
2025-12-02 20:09:42 +05:30
const activityId = event.pathParameters?.activityId;
2025-11-27 19:47:04 +05:30
if (!activityId) {
throw new ApiError(400, 'activityId is required');
}
await minglarService.rejectPQQbyAM(
Number(activityId),
2025-12-03 12:44:07 +05:30
Number(userInfo.id)
2025-11-27 19:47:04 +05:30
);
return {
statusCode: 201,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify({
success: true,
2025-12-02 20:09:42 +05:30
message: 'Rejected PQ successfully',
2025-11-27 19:47:04 +05:30
data: null,
}),
};
});