All checks were successful
SSH Backend Deploy / ssh-deploy (push) Successful in 9s
181 lines
5.5 KiB
JavaScript
181 lines
5.5 KiB
JavaScript
// src/config/index.js
|
|
const path = require('path');
|
|
|
|
// Configuration centralisée de l'application
|
|
module.exports = {
|
|
// Configuration du serveur
|
|
server: {
|
|
port: process.env.PORT || 3000,
|
|
cors: {
|
|
origins: ['http://127.0.0.1:5500', 'http://localhost:5500', 'http://localhost:3000'],
|
|
methods: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
allowedHeaders: ['Content-Type'],
|
|
credentials: true
|
|
}
|
|
},
|
|
|
|
// Configuration de la base de données
|
|
database: {
|
|
host: process.env.DB_HOST || 'timelapse-db',
|
|
port: process.env.DB_PORT || 5432,
|
|
user: process.env.DB_USER || 'postgres',
|
|
password: process.env.DB_PASSWORD || 'postgres',
|
|
database: process.env.DB_NAME || 'timelapse',
|
|
reconnectInterval: 3000
|
|
},
|
|
|
|
// Configuration de Swagger
|
|
swagger: {
|
|
definition: {
|
|
openapi: '3.0.0',
|
|
info: {
|
|
title: 'API Timelapse',
|
|
version: '1.0.0',
|
|
description: 'Documentation de l\'API Timelapse pour la gestion des projets, mesures et vidéos',
|
|
contact: {
|
|
name: 'Support Timelapse',
|
|
email: 'support@timelapse.kerboul.me'
|
|
}
|
|
},
|
|
servers: [
|
|
{ url: 'https://timelapse.kerboul.me/api', description: 'Serveur de production' },
|
|
{ url: 'http://localhost:3000/api', description: 'Serveur de développement local' }
|
|
],
|
|
components: {
|
|
schemas: {
|
|
Project: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer' },
|
|
name: { type: 'string' },
|
|
description: { type: 'string' },
|
|
start_date: { type: 'string', format: 'date' },
|
|
status: { type: 'integer' }
|
|
}
|
|
},
|
|
Measurement: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer' },
|
|
project_id: { type: 'integer' },
|
|
timestamp: { type: 'string', format: 'date-time' },
|
|
path: { type: 'string' },
|
|
temperature: { type: 'number' },
|
|
humidity: { type: 'number' },
|
|
order_id: { type: 'integer' }
|
|
}
|
|
},
|
|
Video: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer' },
|
|
project_id: { type: 'integer' },
|
|
measurement_ids: { type: 'string' },
|
|
name: { type: 'string' },
|
|
resolution: { type: 'string' },
|
|
duration: { type: 'integer' },
|
|
status: { type: 'integer' },
|
|
progress: { type: 'number' },
|
|
video_file: { type: 'string', nullable: true },
|
|
started_at: { type: 'string', format: 'date-time', nullable: true },
|
|
updated_at: { type: 'string', format: 'date-time', nullable: true },
|
|
eta: { type: 'number', nullable: true }
|
|
}
|
|
},
|
|
Camera: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer' },
|
|
interval: { type: 'integer', nullable: true },
|
|
maintenance: { type: 'integer' },
|
|
active: { type: 'integer' }
|
|
}
|
|
},
|
|
Error: {
|
|
type: 'object',
|
|
properties: {
|
|
message: { type: 'string' },
|
|
statusCode: { type: 'integer' },
|
|
details: { type: 'string', nullable: true },
|
|
timestamp: { type: 'string', format: 'date-time' }
|
|
}
|
|
}
|
|
},
|
|
responses: {
|
|
NotFound: {
|
|
description: 'La ressource demandée n\'a pas été trouvée',
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
$ref: '#/components/schemas/Error'
|
|
}
|
|
}
|
|
}
|
|
},
|
|
BadRequest: {
|
|
description: 'Requête invalide',
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
$ref: '#/components/schemas/Error'
|
|
}
|
|
}
|
|
}
|
|
},
|
|
ServerError: {
|
|
description: 'Erreur serveur',
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
$ref: '#/components/schemas/Error'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
tags: [
|
|
{ name: 'Projets', description: 'Opérations relatives aux projets' },
|
|
{ name: 'Mesures', description: 'Opérations relatives aux mesures et images' },
|
|
{ name: 'Vidéos', description: 'Opérations relatives aux vidéos' },
|
|
{ name: 'Caméra', description: 'Opérations relatives au contrôle de la caméra' },
|
|
{ name: 'Images', description: 'Opérations relatives aux images' },
|
|
{ name: 'Système', description: 'Opérations relatives au système' }
|
|
],
|
|
},
|
|
apis: ['./src/routes/*.js'] // Chemins pour la documentation
|
|
},
|
|
|
|
// Chemins des répertoires
|
|
paths: {
|
|
storage: path.join(process.cwd(), 'storage'),
|
|
uploads: path.join(process.cwd(), 'uploads'),
|
|
samples: path.join(process.cwd(), 'sample')
|
|
},
|
|
|
|
// Statuts pour les projets
|
|
projectStatus: {
|
|
brouillon: 0,
|
|
capturing: 1,
|
|
idle: 2,
|
|
},
|
|
|
|
// Statuts pour les vidéos
|
|
videoStatus: {
|
|
rendering: 0,
|
|
completed: 1,
|
|
error: 2
|
|
},
|
|
|
|
// Paramètres par défaut pour la caméra
|
|
camera: {
|
|
defaultSettings: {
|
|
id: 1,
|
|
interval: null,
|
|
nbImages: null,
|
|
maintenance: false,
|
|
stopFlag: false,
|
|
idle: true
|
|
}
|
|
}
|
|
}; |