-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (26 loc) · 777 Bytes
/
server.js
File metadata and controls
33 lines (26 loc) · 777 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
29
30
31
32
33
const express = require('express')
const colors = require('colors')
const helmet = require('helmet')
const {
NODE_ENV_OPTIONS,
EXPRESS_DEFAULT_PORT,
API_BASE_URI,
} = require('./utils/constants')
const servicesRoute = require('./routes/services')
const { createFakeData } = require('./fake/fake-client-requests')
// the app
const app = express()
// MIDDLEWARES
app.use(express.json())
app.use(helmet())
// END OF MIDDLEWARES
app.use(`${API_BASE_URI}`, servicesRoute)
// SET UP THE LISTENING OF EXPRESS SERVER
const PORT = process.env.PORT || EXPRESS_DEFAULT_PORT
const NODE_ENV = process.env.NODE_ENV || NODE_ENV_OPTIONS.DEV
app.listen(PORT, () =>
console.log(
`Express server running at port: ${PORT}, with environment: ${NODE_ENV}`
.green.bold
)
)