my-hapi-server

1.2.0 • Public • Published

my-hapi-server

Create, configure, require and load scripts, strategies, routes, and return a Hapi server

Example

Here we pass in server and connection options as well as describe the folder conventions.

The server will be created, setup, and passed back, ready for testing or for calling start on.

module.exports = require('my-hapi-server')(__dirname+'/src', {
  server: {
    connections: { routes: { cors: true } },
    //debug: { 'request': ['error', 'uncaught'] }
  },
  connection: {
    port: process.env.PORT
  },
  loader: {
    auth: {
      glob: 'auth/**/*.js',
      leaf: function(i) { return i.length === 3; }
    },
    routes: {
      glob: 'routes/**/*.js',
      leaf: function(i) { return i.handler; }
    },
    plugins: {
      glob: 'plugins/**/*.js',
      leaf: function(i) { return i.register; }
    }
  }
}).then(function(server) {
  server.start();
})

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i my-hapi-server

    Weekly Downloads

    2

    Version

    1.2.0

    License

    ISC

    Last publish

    Collaborators

    • keyvanfatehi