Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 1.33 KB

README.md

File metadata and controls

36 lines (29 loc) · 1.33 KB

Hapi Route Autoloader

Build Status npm version

A Hapi plugin that provides an auto-loader for Hapi routes from a specified directory.

Install

yarn

yarn add @videoamp/hapi-route-autoloader

npm

npm install --save @videoamp/hapi-route-autoloader

Setup

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

Folder Structure

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.