Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

kfatehi/node--my-hapi-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

my-hapi-server

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

Uses my-loader under the hood.

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();
})

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published