This commit is contained in:
2025-02-01 22:35:39 +09:00
parent c164491dcb
commit fa10a84380
6 changed files with 6328 additions and 19 deletions

View File

@@ -1,4 +1,7 @@
const {Sequelize} = require('sequelize')
const { Sequelize } = require('sequelize')
/* const dotenv = require('dotenv'); */
require('dotenv').config();
module.exports = new Sequelize(
process.env.DB_NAME, // Название БД
@@ -6,7 +9,19 @@ module.exports = new Sequelize(
process.env.DB_PASSWORD, // ПАРОЛЬ
{
dialect: 'postgres',
host: '192.168.192.150',
port: '5432'
host: process.env.DB_HOST,
port: process.env.DB_PORT
}
)
)
const connectDb = async () => {
try {
await client.connect();
console.log('Подключение к PostgreSQL успешно');
} catch (error) {
console.error('Ошибка подключения:', error.stack);
}
};
module.exports = { Sequelize, connectDb };