Package Exports
- @h4ad/serverless-adapter
- @h4ad/serverless-adapter/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@h4ad/serverless-adapter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🚀 Serverless Adapter
Install | Usage | Support | Examples | Architecture | Credits
Run REST APIs and other web applications using your existing Node.js application framework (Express, Koa, Hapi, Fastify and tRPC), on top of AWS Lambda, Azure, Huawei and many other clouds.
This library was a refactored version of @vendia/serverless-express, I create a new way to interact and extend event sources by creating contracts to abstract the integrations between each library layer.
Why you would use this libray instead of @vendia/serverless-express?
- Better APIs to extend library functionality.
- You don't need me to release a new version to integrate with the new event source, you can create an adapter and
just call the
addAdapter
method when building your handler.
- You don't need me to release a new version to integrate with the new event source, you can create an adapter and
just call the
- All code can be extended, if you want to modify the current behavior you can.
- This is important because if you find a bug, you can quickly resolve it by extending the class, and then you can submit a PR to fix the bug.
- All code was written in Typescript.
- Well documented, any method, class, or interface has comments to explain the behavior.
- We have >99% coverage.
Usage
To start to use, first you need to know what you need to import, let's start showing the ServerlessAdapter.
import { ServerlessAdapter } from '@h4ad/serverless-adapter';
We need to pass to Serverless Adapter the instance of your api, let's look an example with:
- Framework: Express.
- Adapters: AWS Api Gateway V2 Adapter.
- Handler: Default Handler.
- Resolver: Promise Resolver.
import { ServerlessAdapter } from '@h4ad/serverless-adapter';
import { ExpressFramework } from '@h4ad/serverless-adapter/lib/frameworks/express';
import { DefaultHandler } from '@h4ad/serverless-adapter/lib/handlers/default';
import { PromiseResolver } from '@h4ad/serverless-adapter/lib/resolvers/promise';
import { ApiGatewayV2Adapter } from '@h4ad/serverless-adapter/lib/adapters/aws';
const express = require('express');
const app = express();
export const handler = ServerlessAdapter.new(app)
.setFramework(new ExpressFramework())
.setHandler(new DefaultHandler())
.setResolver(new PromiseResolver())
.addAdapter(new ApiGatewayV2Adapter())
// if you need more adapters
// just append more `addAdapter` calls
.build();
Documentation
See how to use this library here.
Examples
You can see some examples of how to use this library here.
Credits
Honestly, I just refactored all the code that the @vendia team and many other contributors wrote, thanks so much to them for existing and giving us a brilliant library that is the core of my current company.
Sponsors
![]() |
---|