Skip to content

Commit 919bbab

Browse files
Merge pull request #5 from Tsalmas-Anastasios/release/1.0.1
Release/1.0.1
2 parents 59e492f + 40a3b50 commit 919bbab

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-express-api-template",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Template for API using Node, ExpressJS, Sequelize ORM for PostgresDB, PostgresDB, Zod and Pino logger",
55
"keywords": [
66
"api",

server/.sequelize.cjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const path = require('node:path');
22

33
module.exports = {
4-
config: path.resolve(__dirname, 'src/config/database.config.ts'),
4+
config: path.resolve(
5+
__dirname,
6+
'src/config/integrations/database/data.database.integrations.config.ts'
7+
),
58
'migrations-path': path.resolve(__dirname, 'src/db/migrations'),
69
'seeders-path': path.resolve(__dirname, 'src/db/seeders'),
710
'models-path': path.resolve(__dirname, 'src/models'),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Sequelize } from 'sequelize';
2+
3+
import { appConfig } from '../../config/index.config.ts';
4+
5+
export const database: Sequelize = new Sequelize({
6+
dialect: 'postgres',
7+
host: appConfig.integrations.databases.data.host,
8+
port: appConfig.integrations.databases.data.port,
9+
database: appConfig.integrations.databases.data.database,
10+
username: appConfig.integrations.databases.data.username,
11+
password: appConfig.integrations.databases.data.password,
12+
// logging: appConfig.database.logging,
13+
});
14+
15+
export async function assertDatabaseConnection(): Promise<void> {
16+
try {
17+
await database.authenticate();
18+
} catch (error) {
19+
console.error('Unable to connect to the database:', error);
20+
throw error;
21+
}
22+
}

0 commit comments

Comments
 (0)