1.0.25 • Published 2 months ago

serverless-h3 v1.0.25

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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.

1.0.22

2 months ago

1.0.25

2 months ago

1.0.24

2 months ago

1.0.23

2 months ago

1.0.21

4 months ago

1.0.20

4 months ago

1.0.19

4 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.12

6 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago