diff --git a/routes/auth/login.ts b/routes/auth/login.ts index e732f3b..640277f 100644 --- a/routes/auth/login.ts +++ b/routes/auth/login.ts @@ -10,6 +10,9 @@ const body = z.object({ password: z.string() }); +/** + * Handles the login route. + */ export default async function Route_Auth_Login(req: Request, res: Response, next: NextFunction) { const bodyPayload = body.safeParse(req.body); diff --git a/routes/auth/me-qr.ts b/routes/auth/me-qr.ts index e980b5b..389808f 100644 --- a/routes/auth/me-qr.ts +++ b/routes/auth/me-qr.ts @@ -3,6 +3,10 @@ import Status from "@/models/status"; import { Request, Response, NextFunction } from "express"; import qr from "qr-base64"; +/** + * Generate a QR code with the user's profile URL. + * Returns the base64 encoded QR code. + */ export default async function Route_Auth_MeQr(req: Request, res: Response, next: NextFunction) { if (!req.user) { return Status.send(req, next, { diff --git a/routes/auth/me.ts b/routes/auth/me.ts index 67658b0..d55dcd3 100644 --- a/routes/auth/me.ts +++ b/routes/auth/me.ts @@ -1,6 +1,9 @@ import Status from "@/models/status"; import { Request, Response, NextFunction } from "express"; +/** + * Returns the authenticated user's UUID + */ export default async function Route_Auth_Me(req: Request, res: Response, next: NextFunction) { if (!req.user) { return Status.send(req, next, { diff --git a/routes/auth/send-mail.ts b/routes/auth/send-mail.ts index 3fdaab9..ce57289 100644 --- a/routes/auth/send-mail.ts +++ b/routes/auth/send-mail.ts @@ -17,6 +17,16 @@ const body = z.object({ email: z.string() }); +/** + * Send an email to the specified email address + * to create a user. + * + * The email address must end with @edu.devinci.fr + * and must not be used by an existing user. + * + * Returns the URL of the creation page if the + * request is from an admin (X-ADMIN-KEY header). + */ export default async function Route_Auth_Sendmail(req: Request, res: Response, next: NextFunction) { const bodyPayload = body.safeParse(req.body); diff --git a/routes/clubs/get.ts b/routes/clubs/get.ts index 6205a4f..fbc9531 100644 --- a/routes/clubs/get.ts +++ b/routes/clubs/get.ts @@ -8,6 +8,9 @@ const params = z.object({ id: znumber() }); +/** + * Get a club by id + */ export default async function Route_Clubs_Get(req: Request, res: Response, next: NextFunction) { const payload = params.safeParse(req.params); if (!payload.success) { diff --git a/routes/clubs/list.ts b/routes/clubs/list.ts index a42e8d1..ec63276 100644 --- a/routes/clubs/list.ts +++ b/routes/clubs/list.ts @@ -2,6 +2,10 @@ import ClubController from "@/controllers/clubs"; import Status from "@/models/status"; import { NextFunction, Request, Response } from "express"; +/** + * Handles the route for listing all clubs. + * Sends a response with a status of 200 and the list of all clubs. + */ export default async function Route_Clubs_List(req: Request, res: Response, next: NextFunction) { return Status.send(req, next, { status: 200, diff --git a/routes/daily.ts b/routes/daily.ts index 4781b69..3b6b56d 100644 --- a/routes/daily.ts +++ b/routes/daily.ts @@ -2,6 +2,11 @@ import ClubController from "@/controllers/clubs"; import Status from "@/models/status"; import { NextFunction, Request, Response } from "express"; +/** + * Handles the /daily route. + * Retrieves the daily club information. + * Sends a response with a status of 200 and the daily club information. + */ export default async function Route_Daily_Read(req: Request, res: Response, next: NextFunction) { const club = await ClubController.getDailyClub(); diff --git a/routes/index.ts b/routes/index.ts index 6e3c59b..e7a9cf0 100644 --- a/routes/index.ts +++ b/routes/index.ts @@ -1,6 +1,10 @@ import Status from "@/models/status"; import { NextFunction, Request, Response } from "express"; +/** + * Handles the / route. + * Sends a response with a status of 204 and no data. + */ export default function Route_Index_Read(req: Request, res: Response, next: NextFunction) { return Status.send(req, next, { status: 204 diff --git a/routes/users/create.ts b/routes/users/create.ts index b93f1f5..ce00f51 100644 --- a/routes/users/create.ts +++ b/routes/users/create.ts @@ -10,6 +10,10 @@ const body = z.object({ token: z.string() }); +/** + * Handles the create user route. + * Creates a new user and returns it. + */ export default async function Route_Users_Create(req: Request, res: Response, next: NextFunction) { const bodyPayload = body.safeParse(req.body); diff --git a/routes/users/get.ts b/routes/users/get.ts index de53c90..759af64 100644 --- a/routes/users/get.ts +++ b/routes/users/get.ts @@ -7,6 +7,14 @@ const params = z.object({ id: string() }); +/** + * Handles the GET /users/:id route. + * Retrieves the user with the given id + * and sends a response with a status of 200 and the user data. + * + * If the id is invalid, sends a response with a status of 400 and an error message. + * If the user does not exist, sends a response with a status of 404 and an error message. + */ export default async function Route_Users_Get(req: Request, res: Response, next: NextFunction) { const payload = params.safeParse(req.params); if (!payload.success) { diff --git a/routes/users/update.ts b/routes/users/update.ts index a0adcc3..8faaefd 100644 --- a/routes/users/update.ts +++ b/routes/users/update.ts @@ -12,6 +12,11 @@ const body = z.object({ avatarUrl: z.string().optional() }); +/** + * Handles the PUT /users/:id route. + * Updates the user with the given id based on the provided data. + * Sends a response with a status of 200 and the updated user data. + */ export default async function Route_Users_Update(req: Request, res: Response, next: NextFunction) { const paramsPayload = params.safeParse(req.params); const bodyPayload = body.safeParse(req.body);