feat(database): Implement DatabaseManager for managing database structure and initialization
All checks were successful
SSH Backend Deploy / ssh-deploy (push) Successful in 1m51s
All checks were successful
SSH Backend Deploy / ssh-deploy (push) Successful in 1m51s
feat(routes): Add camera, image, measurement, project, and video routes with Swagger documentation feat(services): Create storageService and videoService for file management and video processing fix(errorHandler): Enhance error handling with standardized responses and database operation wrappers
This commit is contained in:
40
db.js
40
db.js
@@ -1,35 +1,9 @@
|
||||
const { Client } = require('pg');
|
||||
/**
|
||||
* Ce fichier est maintenu pour des raisons de compatibilité
|
||||
* mais redirige vers la nouvelle structure de connexion à la base de données.
|
||||
* À terme, toutes les références devraient utiliser src/database/connection.js
|
||||
*/
|
||||
|
||||
const client = new Client({
|
||||
host: 'timelapse-db',
|
||||
port: 5432,
|
||||
user: 'postgres',
|
||||
password: 'postgres',
|
||||
database: 'timelapse'
|
||||
});
|
||||
const db = require('./src/database/connection');
|
||||
|
||||
let isConnecting = false;
|
||||
|
||||
function init_database() {
|
||||
if (isConnecting) {
|
||||
console.log('[DB] Connection attempt already in progress, skipping...');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[DB] Initialisation de la base de données PostgreSQL...');
|
||||
isConnecting = true;
|
||||
|
||||
client.connect(err => {
|
||||
isConnecting = false;
|
||||
|
||||
if (err) {
|
||||
console.error('[DB] Erreur de connexion à la base de données:', err);
|
||||
setTimeout(init_database, 3000);
|
||||
} else {
|
||||
console.log('[DB] Connecté à la base de données PostgreSQL.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
init_database();
|
||||
module.exports = client;
|
||||
module.exports = db;
|
||||
Reference in New Issue
Block a user