made the getbyid pqq question details api
This commit is contained in:
@@ -192,6 +192,22 @@ functions:
|
||||
path: /host/getById
|
||||
method: get
|
||||
|
||||
getPQQQuestionDetailsById:
|
||||
handler: src/modules/host/handlers/getByIdPQQ.handler
|
||||
package:
|
||||
patterns:
|
||||
- 'src/modules/host/handlers/getByIdPQQ.*'
|
||||
- 'src/modules/host/services/**'
|
||||
- 'common/**'
|
||||
- 'src/common/**'
|
||||
- 'node_modules/@prisma/client/**'
|
||||
- 'node_modules/.prisma/**'
|
||||
|
||||
events:
|
||||
- httpApi:
|
||||
path: /host/get-pqq-question-details
|
||||
method: get
|
||||
|
||||
acceptMinglarAgreement:
|
||||
handler: src/modules/host/handlers/acceptAgreement.handler
|
||||
package:
|
||||
|
||||
50
src/modules/host/handlers/getByIdPQQ.ts
Normal file
50
src/modules/host/handlers/getByIdPQQ.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
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';
|
||||
|
||||
const prismaService = new PrismaService();
|
||||
const hostService = new HostService(prismaService);
|
||||
export const handler = safeHandler(async (
|
||||
event: APIGatewayProxyEvent,
|
||||
context?: Context
|
||||
): Promise<APIGatewayProxyResult> => {
|
||||
// Extract token from headers
|
||||
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token'];
|
||||
if (!token) {
|
||||
throw new ApiError(400, 'This is a protected route. Please provide a valid token.');
|
||||
}
|
||||
|
||||
// Verify token and get user info
|
||||
const userInfo = await verifyHostToken(token);
|
||||
const userId = Number(userInfo.id);
|
||||
|
||||
let body: { question_xid: number, activity_xid: number };
|
||||
|
||||
try {
|
||||
body = event.body ? JSON.parse(event.body) : {};
|
||||
} catch (error) {
|
||||
throw new ApiError(400, 'Invalid JSON in request body');
|
||||
}
|
||||
|
||||
const { question_xid, activity_xid } = body;
|
||||
|
||||
// Fetch user with their HostHeader stepper info
|
||||
const pqqQuestionDetails = await hostService.getPQQQuestionDetail(question_xid, activity_xid);
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
message: 'Stepper information retrieved successfully',
|
||||
data: pqqQuestionDetails,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -235,6 +235,17 @@ export class HostService {
|
||||
})
|
||||
}
|
||||
|
||||
async getPQQQuestionDetail(question_xid: number, activity_xid: number) {
|
||||
return await this.prisma.activityPQQheader.findFirst({
|
||||
where: { activityXid: activity_xid, pqqQuestionXid: question_xid },
|
||||
select: {
|
||||
pqqQuestionXid: true,
|
||||
pqqAnswerXid: true,
|
||||
ActivityPQQSupportings: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async addOrUpdateCompanyDetails(
|
||||
user_xid: number,
|
||||
companyData: HostCompanyDetailsInput,
|
||||
|
||||
Reference in New Issue
Block a user