-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (28 loc) · 868 Bytes
/
app.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 path = require('path')
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const compression = require('compression')
const awsServerlessExpressMiddleware = require('aws-serverless-express/middleware')
const app = express()
const router = express.Router()
router.use(compression())
router.use(cors())
router.use(bodyParser.json())
router.use(bodyParser.urlencoded({ extended: true }))
router.use(awsServerlessExpressMiddleware.eventContext())
router.get('/', (req, res) => {
console.log('GET /')
res.status(200).send({
hello: 'there'
})
})
router.get('/hello-world', (req, res) => {
console.log('GET /hello-world')
return res.status(200).send({
thing: 'Thing'
})
})
app.use('/', router)
// Export your express server so you can import it in the lambda function.
module.exports = app