This commit is contained in:
Pablo Martin 2025-06-06 14:59:22 +02:00
parent 3eb9b42a94
commit ea310a17e4
6 changed files with 261 additions and 2 deletions

View file

@ -1,6 +1,9 @@
const CONSTANTS = require("./constants");
const { getDb } = require("./db");
const buildApp = () => {
const db = getDb();
const express = require("express");
const app = express();

View file

@ -11,4 +11,6 @@ CONSTANTS.PATHS.INDEX_PATH = path.join(
"index.html"
);
CONSTANTS.DB_ENGINE = 'postgres';
module.exports = CONSTANTS;

27
src/back/db.js Normal file
View file

@ -0,0 +1,27 @@
const { Sequelize } = require("sequelize");
const dotenv = require("dotenv");
const CONSTANTS = require("./constants");
dotenv.config();
const getDb = () => {
const sequelize = new Sequelize({
dialect: CONSTANTS.DB_ENGINE,
host: process.env.POSTGRES_HOST,
port: process.env.POSTGRES_PORT,
database: process.env.POSTGRES_DB,
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
define: {
timestamps: false,
freezeTableName: true,
underscored: true,
quoteIdentifiers: false,
},
});
return sequelize;
};
module.exports = {getDb};