Skip to content

Commit

Permalink
version 4.3.1 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
William committed Apr 5, 2020
1 parent e28cb02 commit 0bba39c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,49 @@ The goal of event is to ensure a consistent event payload to be sent to other la
- `originalEvent` is the original event object you wish to extend
- `body` is the new body payload being sent that is automatically `JSON.stringify`'ed
- `overrides` is an object that will override anything else in the original event
# Lambda Web Server / Express
Run a webserver on your lambda instance! Express, Koa, etc should now run without a hitch.
This is very similar to [aws-serverless-express](https://github.com/awslabs/aws-serverless-express). The main point being, it's a little more clean and simple to understand
## Example
Your Lambda Handler (usually `index.js`)
```js
const lambdaServer = require('lambdify/server');
const app = require('./app');

exports.handler = lambdaServer(app);
```
`app.js`
```js
const express = require('express');
const app = express();

app.get('/', (req, res) => res.send('Hello World!'));

module.export = app;
```
And for testing locally (I like to name it `server.js`)
```js
const app = require('./app.js');

app.listen(3000, () => console.log('Now Listening'));
```
## Why not use `aws-serverless-express`
This focuses on simplicity and standard use cases. It also doesn't worry about legacy implementations of lambda callback / context use and is focused on Node 10 / 12 support only with an emphasis on async / await code
## Other inspiration
This was originally developed to handle next.js SSR on AWS Lambda. Officially there is no support and although packages like [serverless-nextjs-plugin](https://www.npmjs.com/package/serverless-nextjs-plugin) exist, they require more packages and the serverless deployment system.
Example of Next.js package soon to come
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"files": [
"lib/",
"helpers/",
"router/"
"router/",
"server/"
],
"homepage": "https://github.com/Prefinem/lambdify",
"husky": {
Expand Down

0 comments on commit 0bba39c

Please sign in to comment.