serverless-h3
TypeScript icon, indicating that this package has built-in type declarations

1.0.25 • Public • Published

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:

  1. Create your h3 application and wrap it with the serverless-h3 wrapper.
  2. 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.

Package Sidebar

Install

npm i serverless-h3

Weekly Downloads

32

Version

1.0.25

License

MIT

Unpacked Size

9.18 kB

Total Files

7

Last publish

Collaborators

  • ralphcrisostomo