Huawei Api Gateway
This adapter add support to Huawei Api Gateway inside Huawei Function Graph.
About the Adapter
When you receive an POST
request inside path /users
, this adapter will forward that request to your framework,
so you can just plug this adapter and doesn't need any configuration to work.
To see which options you can customize, see the HuaweiApiGatewayOptions interface.
Usage
To add support to Api Gateway you do the following:
index.ts
import { ServerlessAdapter } from '@h4ad/serverless-adapter';
import { HuaweiApiGatewayAdapter } from '@h4ad/serverless-adapter/adapters/huawei';
import { ExpressFramework } from '@h4ad/serverless-adapter/frameworks/express';
import { DefaultHandler } from '@h4ad/serverless-adapter/handlers/default';
import { CallbackResolver } from '@h4ad/serverless-adapter/resolvers/callback';
import app from './app';
export const handler = ServerlessAdapter.new(app)
.setFramework(new ExpressFramework())
.setHandler(new DefaultHandler())
.setResolver(new CallbackResolver())
.addAdapter(new HuaweiApiGatewayAdapter())
.build();
One important thing
You must use the callback resolver because I couldn't get it to work with the PromiseResolver. Maybe it's a bug in the library or something specific in Huawei, if you have a hint please create an issue.