Files
MinglarBackendNestJS/src/modules/minglaradmin/handlers/getAMDetail_ById.ts
paritosh18 9706e5b66b Refactor handlers to use Zod for request body and query parameter validation
- Updated `resendOtp.ts` to parse and validate request body using Zod.
- Refactored `createPassword.ts` to utilize Zod for body validation.
- Modified `getAMDetail_ById.ts` to implement Zod for path parameter validation.
- Changed `acceptHostApplication.ts` to use Zod for request body validation.
- Updated `addPQQSuggestion.ts` to validate request body with Zod.
- Refactored `addSuggestion.ts` to use Zod for body validation.
- Modified `getAllHostApplicationForAM.ts` to implement Zod for query parameter validation.
- Changed `getByIdHostDetails.ts` to use Zod for path parameter validation.
- Updated `rejectHostApplicationAM.ts` to validate request body with Zod.
- Refactored `rejectPQQbyAM.ts` to use Zod for body validation.
- Modified `acceptHostAppMinglar.ts` to implement Zod for request body validation.
- Changed `assignAM.ts` to use Zod for request body validation.
- Updated `editAgreementDetails.ts` to validate request body with Zod.
- Refactored `getAllActivityOfHost.ts` to implement Zod for path and query parameter validation.
- Changed `rejectHostApplication.ts` to use Zod for request body validation.
- Updated `loginForMinglar.ts` to validate request body with Zod.
- Refactored `registration.ts` to implement Zod for request body validation.
- Modified `getAllCoadminAndAM.ts` to use Zod for query parameter validation.
- Changed `getAllInvitationDetails.ts` to implement Zod for query parameter validation.
- Updated `getAllInvitedCoadminAndAM.ts` to validate query parameters with Zod.
- Refactored `inviteTeammate.ts` to use Zod for request body validation.
- Modified `getBranchByBank.ts` to implement Zod for query parameter validation.
- Changed `getCityByState.ts` to use Zod for query parameter validation.
2025-11-29 19:39:28 +05:30

58 lines
1.8 KiB
TypeScript

import {
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context,
} from 'aws-lambda';
import { safeHandler } from '../../../common/utils/handlers/safeHandler';
import { PrismaService } from '../../../common/database/prisma.service';
import { MinglarService } from '../services/minglar.service';
import ApiError from '../../../common/utils/helper/ApiError';
import { verifyMinglarAdminToken } from '../../../common/middlewares/jwt/authForMinglarAdmin';
import { parseQueryParams } from '../../../common/utils/validation/validation.utils';
import { getAmDetailByIdPathSchema } from '../../../common/utils/validation/prepopulate/prepopulate.validation';
const prismaService = new PrismaService();
const minglarService = new MinglarService(prismaService);
/**
* Get AM details by ID handler
*/
export const handler = safeHandler(
async (
event: APIGatewayProxyEvent,
context?: Context,
): Promise<APIGatewayProxyResult> => {
// Verify authentication token
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.',
);
}
await verifyMinglarAdminToken(token);
// Parse and validate path params using Zod
const { amXid } = parseQueryParams(event.pathParameters, getAmDetailByIdPathSchema);
// Get AM details by ID from service
const getAmDetailsByid = await minglarService.getAMdetailById(amXid);
return {
statusCode: 200,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify({
success: true,
message: 'Account Manager details retrieved successfully',
data: getAmDetailsByid,
}),
};
},
);