refont back express

This commit is contained in:
jleroy
2025-03-11 10:29:18 +01:00
parent f944b99172
commit 4e41294eee
18 changed files with 507 additions and 9 deletions

16
backend/config/cors.js Normal file
View File

@@ -0,0 +1,16 @@
import dotenv from 'dotenv';
import * as path from "node:path";
const envFile = `.env`;
dotenv.config({ path: path.resolve(process.cwd(), envFile), override: true });
const allowedOrigin = process.env.ALLOWED_ORIGIN || 'http://localhost:4200';
const corsOptions = {
origin: allowedOrigin,
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
};
export default corsOptions;

13
backend/config/db.js Normal file
View File

@@ -0,0 +1,13 @@
import mariadb from 'mariadb';
import dotenv from 'dotenv';
dotenv.config();
const pool = mariadb.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE
});
export default pool;