| 23 | import { createUserSchema } from "./schema/user.schema"; |
| 24 | |
| 25 | function routes(app: Express) { |
| 26 | /** |
| 27 | * @openapi |
| 28 | * /healthcheck: |
| 29 | * get: |
| 30 | * tags: |
| 31 | * - Healthcheck |
| 32 | * description: Responds if the app is up and running |
| 33 | * responses: |
| 34 | * 200: |
| 35 | * description: App is up and running |
| 36 | */ |
| 37 | app.get("/healthcheck", (req: Request, res: Response) => res.sendStatus(200)); |
| 38 | |
| 39 | /** |
| 40 | * @openapi |
| 41 | * '/api/users': |
| 42 | * post: |
| 43 | * tags: |
| 44 | * - User |
| 45 | * summary: Register a user |
| 46 | * requestBody: |
| 47 | * required: true |
| 48 | * content: |
| 49 | * application/json: |
| 50 | * schema: |
| 51 | * $ref: '#/components/schemas/CreateUserInput' |
| 52 | * responses: |
| 53 | * 200: |
| 54 | * description: Success |
| 55 | * content: |
| 56 | * application/json: |
| 57 | * schema: |
| 58 | * $ref: '#/components/schemas/CreateUserResponse' |
| 59 | * 409: |
| 60 | * description: Conflict |
| 61 | * 400: |
| 62 | * description: Bad request |
| 63 | */ |
| 64 | app.post("/api/users", validateResource(createUserSchema), createUserHandler); |
| 65 | |
| 66 | /** |
| 67 | * @openapi |
| 68 | * '/api/sessions': |
| 69 | * get: |
| 70 | * tags: |
| 71 | * - Session |
| 72 | * summary: Get all sessions |
| 73 | * responses: |
| 74 | * 200: |
| 75 | * description: Get all sessions for current user |
| 76 | * content: |
| 77 | * application/json: |
| 78 | * schema: |
| 79 | * $ref: '#/components/schemas/GetSessionResponse' |
| 80 | * 403: |
| 81 | * description: Forbidden |
| 82 | * post: |