@matthewglover/hapi-wrapper

0.2.5 • Public • Published

Build Status Coverage Status Dependencies

Hapi Wrapper

What

A Promise-based wrapper around Hapi.

Why

Hapi has a number of hooks for configuring a server, some of which can be asynchronous. Hapi Wrapper uses Promises and simple functions which allow the different configuration steps to be composed together.

Hapi-Wrapper also includes Inert by default when you add routes configured to serve static resources from the ./public folder.

How

To include in your project run:

npm install --save @matthewglover/hapi-wrapper.

To create a server:

const {
  createServer,
  setConnection,
  registerPlugins,
  addRoutes,
  startServer } = require('@matthewglover/hapi-wrapper');

const port = process.env.PORT || 4000;

createServer()
  .then(setConnection({ port }))
  .then(registerPlugins())
  .then(addRoutes())
  .then(startServer)
  .then(server => console.log(`Server running at: ${server.info.uri}`))
  .catch(err => console.log(err));

Readme

Keywords

none

Package Sidebar

Install

npm i @matthewglover/hapi-wrapper

Weekly Downloads

1

Version

0.2.5

License

MIT

Last publish

Collaborators

  • matthewglover