Skip to content

Instantly share code, notes, and snippets.

@userhooke
Created October 13, 2019 15:41
Show Gist options
  • Save userhooke/24450b59159d063d76cdc1d8ae627b61 to your computer and use it in GitHub Desktop.
Save userhooke/24450b59159d063d76cdc1d8ae627b61 to your computer and use it in GitHub Desktop.
Simple Express server to test Lambda functions locally
const express = require('express');
// path to lambda function
const getAccountDetails = require('../get-account-details/src/index');
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.post('/', async (req, res) => {
// calling lambda function
return getAccountDetails.handler({
body: JSON.stringify({
password: req.body.password,
edrpou: req.body.edrpou,
}),
})
.then(response => response)
.catch(error => error);
});
app.listen(process.env.PORT, () => console.log(`App listening on port ${process.env.PORT}!`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment