-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
43 lines (32 loc) · 845 Bytes
/
index.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
39
40
41
42
43
require('dotenv').config()
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const morgan = require('morgan')
const customerRoute = require('./routes/customers.routes')
const weatherRoute = require('./routes/weather.routes')
const port = process.env.PORT
// parse application/json
app.use(bodyParser.json())
app.listen(port, () => {
console.log(`i am listening on ${port}`)
})
app.use(morgan('combined'))
app.use(customerRoute)
app.use(weatherRoute)
app.get('/', (req, res) => {
res.status(200).send({
status: "error",
message: "You might sink, if you come here again",
data: []
})
})
/*
Error 404
*/
app.use((req, res, next) => {
res.status(404).send({
status: "error",
message: "404 Not found"
})
})