-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 799 Bytes
/
index.js
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
29
30
31
32
33
34
35
36
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const morgan = require('morgan');
const helmet = require('helmet');
const router = require('./router/routes');
const db = require('./models');
const app = express();
const port = process.env.PORT;
const corsConfig = {
origin: 'http://localhost:19002',
// credentials: true,
};
app.use(morgan('dev'));
app.use(helmet());
app.use(cors(corsConfig));
app.use(express.json());
app.use(router);
db.sequelize
.sync() // { force: true }
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});
app.listen(port, () => {
console.log(`Serving you up on http://localhost:${port}`);
});