serverless-hapi
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

serverless-hapi

Use hapi with the serverless framework.

The latest version of serverless-hapi works with hapi >= 17. For usage with hapi 16, use version 2.0.x of serverless-hapi. See 2.0.x branch.

Works with Amazon Lambda and Azure Functions.

Usage

A simple usage example:

import {APIGatewayEvent, Callback, Context} from 'aws-lambda'
import * as hapi from 'hapi'
import {serverlessHapi, ResponseData} from 'serverless-hapi'
 
const app = () => {
  const server = new hapi.Server()
 
  server.route({
    method: 'GET',
    path: '/hello',
    handler: _request => ({message: 'Hello from hapi!'}),
  })
 
  return server
}
 
const onInitError = (error: Error) => {
  console.error(error)
  throw error
}
 
export const hello: (
  eventAPIGatewayEvent,
  contextContext,
  callbackCallback
) => Promise<ResponseData | Error> = serverlessHapi(app(), onInitError)

For more examples, check out the example folder.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Readme

Keywords

none

Package Sidebar

Install

npm i serverless-hapi

Weekly Downloads

77

Version

3.0.2

License

Apache-2.0

Unpacked Size

39.1 kB

Total Files

8

Last publish

Collaborators

  • drager