restify-utils

1.6.8 • Public • Published

Restify Utils

Install

npm i restify-utils -S

Usage

Main function

const attach = require('restify-utils')(configuration, endpointsDir, middlewareDir)

returns Function:

  1. Function(server, family, prefix = '/api') with extra properties:
  2. endpoints
  3. middleware

Populates configuration.models

Goes through endpoints, that are in format of the following:

exports.VERB = {
  path: '/path/relative/to/prefix/family',
  middleware: [ 'middlewareName' ],
  handlers: {
    '1.0.0': function handler(req, res, next) {
 
    },
    '1.1.0': function xxx(req, res, next) {
 
    }
  },
};

It will be attached to VERB ${prefix}/${family}/path/relative/to/prefix/family with 2 versions: 1.0.0 and 1.1.0

Endpoints, middleware, models

  1. Models - instances of classes in the models folder:
  • User
  1. Endpoints - endpoints from the endpointsDir
  2. Middleware - middleware from the middlewareDir

Readme

Keywords

none

Package Sidebar

Install

npm i restify-utils

Weekly Downloads

1

Version

1.6.8

License

MIT

Last publish

Collaborators

  • avvs