made the getbyid pqq question details api

This commit is contained in:
2025-11-22 19:30:16 +05:30
parent 3b1aac921f
commit 1377e0ba9a
3 changed files with 77 additions and 0 deletions

View File

@@ -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:

View 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,
}),
};
});

View File

@@ -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,