2.4.0 • Published 6 years ago

restify-route-loader v2.4.0

Weekly downloads
18
License
ISC
Repository
github
Last release
6 years ago

restify-route-loader

A module to automate route loading for Restify.

Installation

npm i restify-route-loader -S

Usage

import restify from 'restify';
import routeLoader from 'restify-route-loader';

const server = restify.createServer();

server.use(routeLoader(server));

server.listen(port, () => {});

Folder Structure

-/routes
--get.js
--/aboutus
---get.js
---post.js
-/routes
--get-1.0.0.js
--get-1.1.0.js
--/aboutus
---get.js
---post.js

File Setup

If the file is just the verb without the version, include the version within the file

exports.default = [
  {
    version: "1.0.0",
    controller: function(req, res, next) {
      return res.send('Hello World')
    }
  }
]

Configuration

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

server.use(routeLoader(server, {
    routes: path.join(__dirname, 'routes')
}));

Options

routes Change the folder to look for routes

  • Defaults to routes/ inside the current working directory

verbs Enable loading of additional HTTP methods

  • Must be supported by Restify
  • Defaults to get, post, del, put

TODO

  • Update (create) documentation
  • Add build process
2.4.0

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.1.0-rc4

7 years ago

2.1.0-rc3

7 years ago

2.1.0-rc2

7 years ago

2.1.0-rc1

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

8 years ago