generated from nhcarrigan/template
All checks were successful
Node.js CI / Lint and Test (push) Successful in 1m51s
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
/**
|
|
* @copyright nhcarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
import { reviewHandler } from "../handlers/review/generateHandlers.js";
|
|
import type { DatabasePath } from "../interfaces/databasePath.js";
|
|
import type { WrappedRoute } from "../interfaces/wrappedRoute.js";
|
|
import type {
|
|
ErrorResponse,
|
|
ReviewRequest,
|
|
SuccessResponse,
|
|
} from "@repo/types";
|
|
|
|
/**
|
|
* Handles all of the routes to `/review/{type}` a form submission.
|
|
* @param database - The Prisma client.
|
|
* @returns A Fastify plugin.
|
|
*/
|
|
export const reviewRoutes: WrappedRoute = (database) => {
|
|
return async(fastify) => {
|
|
const routes: Array<DatabasePath> = [
|
|
"appeals",
|
|
"commissions",
|
|
"contacts",
|
|
"events",
|
|
"meetings",
|
|
"mentorships",
|
|
"staff",
|
|
"testimonials",
|
|
];
|
|
for (const route of routes) {
|
|
fastify.put<{
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Fastify convention.
|
|
Body: ReviewRequest;
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Fastify convention.
|
|
Reply: SuccessResponse | ErrorResponse;
|
|
}>(`/review/${route}`, async(request, response) => {
|
|
await reviewHandler(database, route, { request, response });
|
|
});
|
|
}
|
|
};
|
|
};
|