-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (27 loc) · 759 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
const express = require('express')
const app = express()
const port = process.env.PORT || 8000
app.use(express.json())
app.use(function (req, res, next) {
console.log("== Request received")
console.log(" - METHOD:", req.method)
console.log(" - URL:", req.url)
console.log(" - HEADERS:", req.headers)
next()
})
app.get('/', function (req, res, next) {
res.status(200).send({
msg: "Hello, world!"
})
})
app.get('/lodgings', function (req, res, next) {
res.status(200).send({})
})
app.use('*', function (req, res, next) {
res.status(404).send({
err: "This URL was not recognized: " + req.originalUrl
})
})
app.listen(port, function () {
console.log("== Server is listening on port:", port)
})