An open API service indexing awesome lists of open source software.

https://github.com/pplu/mojo-plugin-lambda

A mojojs plugin to enable MojoJS apps to run in AWS Lambda
https://github.com/pplu/mojo-plugin-lambda

Last synced: about 1 year ago
JSON representation

A mojojs plugin to enable MojoJS apps to run in AWS Lambda

Awesome Lists containing this project

README

          

# mojo-plugin-lambda

Run your mojojs application inside AWS Lambda

```
npm install mojo-plugin-lambda
```

In your mojojs code:

```
import lambdaPlugin from 'mojo-plugin-lambda';
```

Then after `const app = mojo();` enable the plugin

```
app.plugin(lambdaPlugin, {});
const handler = app.handler;
export { handler };
```

This installs a handler function for AWS Lambda to invoke. Set your Lambdas entrypoint to `appfile.handler`
(where `appfile` is the main file of your application.

Finally, delete `app.start()` from the end of your application file. You can alternatively invoke it whenever
it is not running inside a Lambda environment.

```
if (! process.env.AWS_LAMBDA_FUNCTION_NAME) {
app.start();
}
```

Zip your code (or create a Lambda Container Image), upload it, and profit

## Author

Jose Luis Martinez Torres

## Copyright

(c) Jose Luis Martinez Torres 2022

## License

Apache 2