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
- Host: GitHub
- URL: https://github.com/pplu/mojo-plugin-lambda
- Owner: pplu
- Created: 2022-06-30T15:31:48.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-01T22:21:23.000Z (almost 4 years ago)
- Last Synced: 2025-03-15T10:34:37.170Z (over 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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