Files
timelapse-backend/src/routes/projectRoutes.js

208 lines
5.7 KiB
JavaScript

// src/routes/projectRoutes.js
const express = require('express');
const router = express.Router();
const ProjectController = require('../controllers/projectController');
/**
* @swagger
* /projects:
* get:
* tags:
* - Projets
* summary: Récupère tous les projets
* description: Retourne la liste complète des projets de timelapse
* responses:
* 200:
* description: Liste de tous les projets
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Project'
* 500:
* $ref: '#/components/responses/ServerError'
*/
router.get('/projects', ProjectController.getAllProjects);
/**
* @swagger
* /projects/{id}:
* get:
* tags:
* - Projets
* summary: Récupère un projet par ID
* description: Retourne les détails d'un projet spécifique
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: ID du projet
* responses:
* 200:
* description: Détails du projet
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Project'
* 400:
* $ref: '#/components/responses/BadRequest'
* 404:
* $ref: '#/components/responses/NotFound'
* 500:
* $ref: '#/components/responses/ServerError'
*/
router.get('/projects/:id', ProjectController.getProjectById);
/**
* @swagger
* /projects/{id}/videos:
* get:
* tags:
* - Projets
* - Vidéos
* summary: Récupère les vidéos d'un projet
* description: Retourne toutes les vidéos associées à un projet spécifique
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: ID du projet
* responses:
* 200:
* description: Liste des vidéos du projet
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Video'
* 400:
* $ref: '#/components/responses/BadRequest'
* 404:
* $ref: '#/components/responses/NotFound'
* 500:
* $ref: '#/components/responses/ServerError'
*/
router.get('/projects/:id/videos', ProjectController.getProjectVideos);
/**
* @swagger
* /projects/{id}/measurements:
* get:
* tags:
* - Projets
* - Mesures
* summary: Récupère les mesures d'un projet
* description: Retourne toutes les mesures associées à un projet spécifique
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: ID du projet
* responses:
* 200:
* description: Liste des mesures du projet
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Measurement'
* 400:
* $ref: '#/components/responses/BadRequest'
* 404:
* $ref: '#/components/responses/NotFound'
* 500:
* $ref: '#/components/responses/ServerError'
*/
router.get('/projects/:id/measurements', ProjectController.getProjectMeasurements);
/**
* @swagger
* /projects:
* post:
* tags:
* - Projets
* summary: Crée un nouveau projet
* description: Crée un nouveau projet de timelapse et son répertoire de stockage
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* name:
* type: string
* description: Nom du projet
* description:
* type: string
* description: Description détaillée du projet
* required:
* - name
* - description
* responses:
* 201:
* description: Projet créé avec succès
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Projet ajouté avec succès
* id:
* type: integer
* example: 42
* 400:
* $ref: '#/components/responses/BadRequest'
* 500:
* $ref: '#/components/responses/ServerError'
*/
router.post('/projects', ProjectController.createProject);
/**
* @swagger
* /projects/{id}:
* delete:
* tags:
* - Projets
* summary: Supprime un projet
* description: Supprime un projet, toutes ses mesures, images et vidéos associées
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: ID du projet à supprimer
* responses:
* 200:
* description: Projet supprimé avec succès
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Projet supprimé avec succès
* id:
* type: integer
* example: 42
* 400:
* $ref: '#/components/responses/BadRequest'
* 500:
* $ref: '#/components/responses/ServerError'
*/
router.delete('/projects/:id', ProjectController.deleteProject);
module.exports = router;