-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (27 loc) · 915 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
var express = require('express');
var bodyParser = require('body-parser');
let apiVersion = {
v1: '/api/v1'
}
let app = express()
let welcomeRoute = require('./api/routes/welcome')
let newsRoute = require('./api/routes/news')
let clearRoute = require('./api/routes/clear')
let queryRoute = require('./api/routes/query')
let noteRoute = require('./api/routes/note')
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }))
app.get('/', async (req, res) => {
res.send('server working')
})
app.use(`${apiVersion.v1}/news`, newsRoute);
app.use(`${apiVersion.v1}/welcome`, welcomeRoute);
app.use(`${apiVersion.v1}/clear`, clearRoute);
app.use(`${apiVersion.v1}/query`, queryRoute);
app.use(`${apiVersion.v1}/notes`, noteRoute)
app.listen(process.env.PORT || 4000, (err) => {
if (err)
throw err;
else
console.log(`App is listening to ${process.env.PORT}`)
});