0.3.1 • Published 8 years ago

simple-route-loader v0.3.1

Weekly downloads
5
License
ISC
Repository
github
Last release
8 years ago

Simple Route Loader

A simple module to autoload ExpressJS routers.

Installation

npm i simple-route-loader --save

Example

Simply require the module and pass in your Express app..

require('simple-route-loader')(app);

and create a router..

'use strict';

var router = module.exports = require('express').Router();

router.route('/')
    .get(function (req, res) {
        res.send('Look, ma!');
    });

Configuration

The module accepts a configuration object as an optional second parameter.

require('simple-route-loader')(app, {
    dir: __dirname
});

Options

dir Change the folder to look for routers

  • Can be a String or an Array. If a String is passed, it is cast to an Array;
  • Defaults to the current working directory.

file Change the name of files to load

  • Can be a String or an Array. If a String is passed, it is cast to an Array;
  • Defaults to the router.js.

preserveTree Use the actual file path of the router

  • Can be a Boolean or a String. If a String is passed, it is cast to a Boolean;
  • Defaults to true.

Told you it's simple.

0.3.1

8 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago