1.0.25 • Published 30 days ago

serverless-h3 v1.0.25

Weekly downloads
-
License
MIT
Repository
github
Last release
30 days 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

30 days ago

1.0.25

30 days ago

1.0.24

30 days ago

1.0.23

30 days ago

1.0.21

3 months ago

1.0.20

3 months ago

1.0.19

3 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.12

5 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago