https://github.com/drager/serverless-hapi
Use hapi with the serverless framework. Works with AWS lambda, Azure functions and Google Cloud Platform functions.
https://github.com/drager/serverless-hapi
aws-lambda azure-functions functions hapi hapijs lambda lambda-functions serverless serverless-framework
Last synced: 9 months ago
JSON representation
Use hapi with the serverless framework. Works with AWS lambda, Azure functions and Google Cloud Platform functions.
- Host: GitHub
- URL: https://github.com/drager/serverless-hapi
- Owner: drager
- License: apache-2.0
- Created: 2018-03-19T21:17:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T23:22:23.000Z (almost 3 years ago)
- Last Synced: 2024-05-01T23:14:21.193Z (over 1 year ago)
- Topics: aws-lambda, azure-functions, functions, hapi, hapijs, lambda, lambda-functions, serverless, serverless-framework
- Language: TypeScript
- Homepage:
- Size: 1.61 MB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# serverless-hapi
Use hapi with the [serverless framework](https://github.com/serverless/serverless).
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](https://github.com/drager/serverless-hapi/tree/2.0.x).
Works with Amazon Lambda and Azure Functions.
## Usage
A simple usage example:
```typescript
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: (
event: APIGatewayEvent,
context: Context,
callback: Callback
) => Promise = serverlessHapi(app(), onInitError)
```
For more examples, check out the [example folder](https://github.com/drager/serverless-hapi/tree/master/example).
## Features and bugs
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/drager/serverless-hapi/issues