Skip to main content

Hapi

First, you need to ensure you have the libs installed, so run this code:

npm i --save @hapi/hapi
npm i --save-dev @types/hapi

Then, you need you just need to use the HapiFramework when you create your adapter, like:

index.ts
import { ServerlessAdapter } from '@h4ad/serverless-adapter';
import { HapiFramework } from '@h4ad/serverless-adapter/frameworks/hapi';

const Hapi = require('@hapi/hapi');

const app = Hapi.server();
export const handler = ServerlessAdapter.new(app)
.setFramework(new HapiFramework())
// continue to set the other options here.
//.setHandler(new DefaultHandler())
//.setResolver(new PromiseResolver())
//.addAdapter(new AlbAdapter())
//.addAdapter(new SQSAdapter())
//.addAdapter(new SNSAdapter())
// after put all methods necessary, just call the build method.
.build();
tip

Is your application instance creation asynchronous? Look the LazyFramework which helps you in asynchronous startup.

tip

Need to deal with CORS? See CorsFramework which helps you to add correct headers.