1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-24 21:39:36 +02:00

Imporved logger

This commit is contained in:
unknown 2021-06-22 14:49:00 +02:00
parent 5ae4d6e7c4
commit e3ed429da1
12 changed files with 89 additions and 55 deletions

15
db.js
View file

@ -1,4 +1,6 @@
const { Sequelize } = require('sequelize');
const Logger = require('./utils/Logger');
const logger = new Logger();
const sequelize = new Sequelize({
dialect: 'sqlite',
@ -9,17 +11,18 @@ const sequelize = new Sequelize({
const connectDB = async () => {
try {
await sequelize.authenticate();
console.log('Connected to database');
logger.log('Connected to database');
const syncModels = false;
const syncModels = true;
if (syncModels) {
console.log('Starting model synchronization');
logger.log('Starting model synchronization');
await sequelize.sync({ alter: true });
console.log('All models were synchronized');
logger.log('All models were synchronized');
}
} catch (error) {
throw new Error(`Unable to connect to the database: ${error.message}`);
logger.log(`Unable to connect to the database: ${error.message}`, 'ERROR');
process.exit(1);
}
}