1.0.14 • Published 5 months ago

hapi-front v1.0.14

Weekly downloads
29
License
MIT
Repository
github
Last release
5 months ago

hapi-front

Deploy powerful, scalable applications, using hapi on top of AWS Lambda and Amazon API Gateway.

About

hapi-front turns your regular hapi server into a serverless function, easily deployable on AWS.

It does so using a translation layer between AWS requests, and regular HTTP requests sent into your hapi server.

Inspired by serverless-http. Tailored for hapi.

Goals

  • Code regular hapi servers, deploy as serverless 🚀
  • Single command deployment
  • No external dependencies

Install

yarn add hapi-front

or

npm install hapi-front --save

Usage

Wrap your current server initialization code with hapi-front:

// server.js
module.exports = async () => {
  const server = Hapi.server({
    port: process.env.port || 3000,
    host: 'localhost'
  })

  // define routes here

  return server 
}


// index.js
const front = require('hapi-front')
const init = require('./server')

module.exports.handler = front(init)

Full Example

See example folder for a full example that uses the Serverless Framework.

Local development

Use serverless-offline plugin to run locally:

serverless offline

Or, simply create a wrapper around server.js to run as a rugaulr hapi server:

const init = require('./server')

let server

const go = async () => {
  server = await init()
  await server.start()
  console.log(`Server ready on ${server.info.uri}`)
}

go()
  .then(console.log)
  .catch(console.log)

Deployment

To deploy:

serverless deploy
1.0.14

5 months ago

1.0.13

6 months ago

1.0.14-beta.1

5 months ago

1.0.12

3 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago