-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (31 loc) · 900 Bytes
/
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
34
35
36
37
38
require("./src/config/config-env")
const path = require("path")
const express = require("express")
const mongoose = require("mongoose")
const bodyParser = require("body-parser")
const morgan = require("morgan")
const cors = require("cors")
const router = require("./src/router")
const app = express()
const port = process.env.PORT
mongoose.Promise = global.Promise
mongoose.connect(process.env.MONGODB_URI)
// View engine
app.set("view engine", "ejs")
app.set("views", path.resolve(__dirname, "views"))
// Middlewares
app.use(morgan("combined"))
app.use(
bodyParser.urlencoded({
extended: true
})
)
app.use(bodyParser.json({ type: "*/*" }))
app.use(cors())
// Set up the static file path
app.use(express.static(path.resolve(__dirname, "assets")))
router(app)
app.listen(port, () => {
console.log(`🌍 Express server is up and running on port: ${port} 🐎`)
})
module.exports = app