1.1.5 • Published 7 years ago

@wize/runtime-load-routes v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

@wize/runtime-load-routes

Description

Registers routes for custom APIs defined in apis directory.

Usage

Installation

npm install --save @wize/runtime-load-routes

Initialize

import runtime from '@wize/runtime-load-routes';
.
.
.
/*
app: koa-app returned from 'const app = createServer({});'
directory: current directory containing all API folders
opts: JSON object; example: {isAPI: true}
events: JSON object containing pre and post events to be attached to each route; example: { pre: [setUserObjectInContext], post: []}
*/
runtime(app, directory, {
    isAPI: true
  }, events);

Sample API directory

project
└───api
│   └───audits
│       └───GET
│           │   index.js
│           │   config.json
│   │   index.js
└───sources
│   └───postgres
│       │   index.js
│   app.js
│   README.md

##License MIT License