diff --git a/apps/api/src/routes/v1/rest/enrollmentHistory/+endpoint.ts b/apps/api/src/routes/v1/rest/enrollmentHistory/+endpoint.ts index e03a8352..a25db7d8 100644 --- a/apps/api/src/routes/v1/rest/enrollmentHistory/+endpoint.ts +++ b/apps/api/src/routes/v1/rest/enrollmentHistory/+endpoint.ts @@ -1,25 +1,24 @@ import { PrismaClient } from "@libs/db"; -import { createErrorResult, createOKResult } from "@libs/lambda"; +import { createHandler } from "@libs/lambda"; import type { EnrollmentHistory } from "@peterportal-api/types"; -import type { APIGatewayProxyHandler } from "aws-lambda"; import { QuerySchema } from "./schema"; const prisma = new PrismaClient(); -export const GET: APIGatewayProxyHandler = async (event, context) => { +export const GET = createHandler(async (event, context, res) => { const { headers, queryStringParameters: query } = event; const { awsRequestId: requestId } = context; const maybeParsed = QuerySchema.safeParse(query); if (!maybeParsed.success) { - return createErrorResult(400, maybeParsed.error, requestId); + return res.createErrorResult(400, maybeParsed.error, requestId); } const { data: { instructor, ...data }, } = maybeParsed; - return createOKResult( + return res.createOKResult( ( await prisma.websocEnrollmentHistory.findMany({ where: { ...data, instructors: { array_contains: instructor } }, @@ -31,4 +30,4 @@ export const GET: APIGatewayProxyHandler = async (event, context) => { headers, requestId, ); -}; +});