forked from Qarun-Qadir-Bissoondial/express-postgres-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (22 loc) · 971 Bytes
/
app.js
File metadata and controls
28 lines (22 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const express = require('express');
const { Sequelize } = require('sequelize');
/*
new Sequelize takes in database name (postgres), username (postgres) and password (password).
It also takes in the host and the dialect of SQL (in this case, Postgres).
If you want another database name, you'll need to go inside PgAdmin and create a new database.
And then put that database name here
const sequelize_connection = new Sequelize('new_database_name', 'postgres', 'password', {
host: 'localhost',
dialect: 'postgres'
});
*/
const sequelize_connection = new Sequelize('postgres', 'postgres', 'password', {
host: 'localhost',
dialect: 'postgres'
});
const app = express();
const port = process.env.PORT || 5000;
sequelize_connection.authenticate()
.then(() => { console.log('Database connected!') })
.catch(error => { console.error(error); });
app.listen(port, () => { console.log(`Listening on port ${port}`); });