-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (29 loc) · 850 Bytes
/
app.js
File metadata and controls
34 lines (29 loc) · 850 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
34
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const app = express()
const orderHandler = require('./handlers/order-handler')
app.use(bodyParser.json())
app.use(
bodyParser.urlencoded({
extended: true
})
)
// CORS: Allow all
app.use(cors({
origin: '*'
}))
let testOrders = []
// COFFEE ORDERS
app.post('/test/new-order', orderHandler.newOrder)
app.put('/test/orders/:id', orderHandler.updateOrder)
app.delete('/test/orders/:id', orderHandler.deleteOrder)
app.get('/test/orders', orderHandler.getAllOrders)
app.get('/test/orders/:id', orderHandler.getOrder)
app.get('/test/clear-orders', orderHandler.clearOrders)
// Port Configuration
const port = process.env.PORT || 3000
// Start listening
app.listen(port, () => {
console.log(`App running on port ${port}`)
})