-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (30 loc) · 1.05 KB
/
server.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
const express = require('express')
const cors = require('cors');
const cookieParser = require('cookie-parser');
require('dotenv').config();
class Application {
constructor(express) {
const app = express();
const db = require("./api/models")
const routes = require('./api/routes')
const controllers = require('./api/controllers')
/* db.sequelize.sync({ force: true }).then(() => {
console.log("En dev : Force la synchro,Drop and re-sync db.");
}); */
app.use(cors())
app.use(cookieParser())
app.use(express.urlencoded({ extended: false }))
app.use(express.json())
app.use(routes(express, controllers));
//app.use(userRouter)
app.listen(process.env.APP_PORT, async () => {
try {
await db.sequelize.authenticate()
} catch (error) {
console.error(error)
}
console.log(`Server listening on ${process.env.APP_PORT}`)
});
}
}
module.exports = new Application(express);