generated from wecode-bootcamp-korea/backend-1st-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
34 lines (26 loc) · 788 Bytes
/
app.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
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const morgan = require('morgan');
const { AppDataSource } = require('./src/models/dataSource');
const { routes } = require('./src/routes');
const PORT = process.env.PORT;
app.use(express.json());
app.use(cors());
app.use(morgan('combined'));
app.use(routes);
const app = express();
app.use(routes);
app.get('/ping', (req, res) => {
res.status(200).json({ message: 'pong' });
});
app.listen(PORT, async () => {
await AppDataSource.initialize()
.then(() => {
console.log('Data Source has been initialize!');
})
.catch((error) => {
console.error('Error during Data Source initialize', error);
});
console.log(`Listening to request on port: ${PORT}`);
});