-
-
Save nikolaymatrosov/bf440061f96aa8627a9e1fae0d8d3278 to your computer and use it in GitHub Desktop.
API GW Express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const serverless = require('serverless-http'); | |
const app = express(); | |
app.use(express.urlencoded({ extended: true })); | |
app.use(express.json()); | |
app.get('/api/info', (req, res) => { | |
res.send({ application: 'sample-app', version: '1.0' }); | |
}); | |
app.get('/api/pet/:name?', (req, res) => { | |
res.send({ ...req.params }); | |
}); | |
module.exports.handler = (event, context) => { | |
const patchedEvent = { | |
...event, | |
path: event.url, | |
originalPath: event.path, | |
} | |
return serverless(app)(patchedEvent, context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment