serverless-h3 v1.0.25
serverless-h3
A serverless wrapper for h3 applications, enabling seamless integration with serverless environments like AWS Lambda.
Installation
To install the package using pnpm, npm or yarn, run the following command:
# PNPM
$ pnpm add serverless-h3
# NPM
$ npm install serverless-h3
# Yarn
$ yarn add serverless-h3
Usage
AWS Lambda Example
To use serverless-h3
with AWS Lambda, follow these steps:
- Create your
h3
application and wrap it with theserverless-h3
wrapper. - Deploy your application to AWS Lambda using a deployment tool like the Serverless Framework, AWS SAM, or AWS CDK.
AWS Lambda Handler
Here's an example of how to set up your handler for AWS Lambda:
javascript:
// handler.js
const serverless = require('serverless-h3');
const { createApp, defineEventHandler, readBody } = require('h3');
const app = createApp();
app.use(defineEventHandler((event) => {
// You can use your h3 methods here..
const body = readBody(event);
return {
hello: 'world',
body: body
}
}));
export const hello = serverless(app);
typescript:
// handler.ts
import serverless from 'serverless-h3';
import { createApp, defineEventHandler, readBody } from 'h3';
const app = createApp();
app.use(defineEventHandler((event) => {
// You can use your h3 methods here..
const body = readBody(event);
return {
hello: 'world',
body: body
}
}));
module.exports.hello = serverless(app);
Contributing
If you have any suggestions, bug reports, or contributions, feel free to open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
2 months ago
2 months ago
2 months ago
2 months ago
4 months ago
4 months ago
4 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago