Suppression du fichier Swagger pour le schéma de mesure et mise à jour des descriptions dans les routes d'images et de projets

This commit is contained in:
2025-02-11 18:30:32 +01:00
parent 08fa489f4c
commit 042ea5cc50
5 changed files with 310 additions and 247 deletions

View File

@@ -17,17 +17,17 @@ const serverError = require('../utils/serverError');
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Project'
* type: object
* 500:
* description: Erreur serveur.
*/
router.get('/projects', async (req, res) => {
try {
const projects = await projectManager.getAllProjects();
res.json(projects);
} catch (error) {
serverError.sendError('Error getting all projects:', res, error);
}
try {
const projects = await projectManager.getAllProjects();
res.json(projects);
} catch (error) {
serverError.sendError('Error getting all projects:', res, error);
}
});
/**
@@ -49,23 +49,23 @@ router.get('/projects', async (req, res) => {
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Project'
* type: object
* 400:
* description: ID de projet invalide.
* 500:
* description: Erreur serveur.
*/
router.get('/projects/:id', async (req, res) => {
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
const project = await projectManager.getProjectById(projectId);
res.json(project);
} catch (error) {
serverError.sendError('Error getting project by ID:', res, error);
}
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
const project = await projectManager.getProjectById(projectId);
res.json(project);
} catch (error) {
serverError.sendError('Error getting project by ID:', res, error);
}
});
/**
@@ -89,23 +89,23 @@ router.get('/projects/:id', async (req, res) => {
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Video'
* type: object
* 400:
* description: ID de projet invalide.
* 500:
* description: Erreur serveur.
*/
router.get('/projects/:id/videos', async (req, res) => {
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
const videos = await projectManager.getVideosByProjectId(projectId);
res.json(videos);
} catch (error) {
serverError.sendError('Error getting videos by project ID:', res, error);
}
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
const videos = await projectManager.getVideosByProjectId(projectId);
res.json(videos);
} catch (error) {
serverError.sendError('Error getting videos by project ID:', res, error);
}
});
/**
@@ -129,23 +129,23 @@ router.get('/projects/:id/videos', async (req, res) => {
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Measurement'
* type: object
* 400:
* description: ID de projet invalide.
* 500:
* description: Erreur serveur.
*/
router.get('/projects/:id/measurements', async (req, res) => {
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
const measurements = await projectManager.getMeasurementsByProjectId(projectId);
res.json(measurements);
} catch (error) {
serverError.sendError('Error getting measurements by project ID:', res, error);
}
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
const measurements = await projectManager.getMeasurementsByProjectId(projectId);
res.json(measurements);
} catch (error) {
serverError.sendError('Error getting measurements by project ID:', res, error);
}
});
/**
@@ -174,17 +174,17 @@ router.get('/projects/:id/measurements', async (req, res) => {
* description: Erreur serveur.
*/
router.post('/projects', async (req, res) => {
const { name, description } = req.body;
if (!name || !description) {
return res.status(400).json({ error: 'Name and description are required' });
}
try {
const project = await projectManager.createProject(name, description, new Date(), 0);
projectManager.createProjectDirectory(project.id);
res.status(201).json({ message: 'Project added successfully', id: project.id });
} catch (error) {
serverError.sendError('Error creating project:', res, error);
}
const { name, description } = req.body;
if (!name || !description) {
return res.status(400).json({ error: 'Name and description are required' });
}
try {
const project = await projectManager.createProject(name, description, new Date(), 0);
projectManager.createProjectDirectory(project.id);
res.status(201).json({ message: 'Project added successfully', id: project.id });
} catch (error) {
serverError.sendError('Error creating project:', res, error);
}
});
/**
@@ -209,17 +209,17 @@ router.post('/projects', async (req, res) => {
* description: Erreur serveur.
*/
router.delete('/projects/:id', async (req, res) => {
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
projectManager.deleteProjectDirectory(projectId);
projectManager.deleteProjectById(projectId);
res.status(200).json({ message: 'Project deleted successfully', id: projectId });
} catch (error) {
serverError.sendError('Error deleting project:', res, error);
}
const projectId = req.params.id;
if (!projectId || isNaN(projectId)) {
return res.status(400).json({ error: 'Invalid project ID' });
}
try {
projectManager.deleteProjectDirectory(projectId);
projectManager.deleteProjectById(projectId);
res.status(200).json({ message: 'Project deleted successfully', id: projectId });
} catch (error) {
serverError.sendError('Error deleting project:', res, error);
}
});
module.exports = router;