A Hapi plugin that provides an auto-loader for Hapi routes from a specified directory.
yarn add @videoamp/hapi-route-autoloader
npm install --save @videoamp/hapi-route-autoloader
This package provides a Hapi plugin which loads routes according from the directory provided to the function. This allows you to customize the directory to load from on a per-project basis.
To use the Hapi plugin, you can require the package directly in server.register
.
An example of server setup is below:
var Hapi = require('hapi');
var server = new Hapi.Server({ port: 8000 });
server.register(require("@videoamp/hapi-route-autoloader")("controllers/"))
.then(() => server.start());
Files inside of the specified directory can export either an array of routes or a single
route object. See the fixtures folder in test/
for an example.