koa-route-mapper

0.0.4 • Public • Published

koa-route-mapper

This middleware will set a /mappers route as default for getting the URLs.

Usage

import Koa from 'koa';
import KoaRouter from 'koa-router';
import KoaMapper from 'koa-route-mapper';
 
let app = new Koa();
const router = new KoaRouter();
 
app.use(KoaMapper('/mappers', [router]));

When visit the /mappers api, it will response:

[
  {
    "path": "/v1/groups/",
    "methods": [
      "HEAD",
      "GET"
    ],
    "function": [
      "getGroups"
    ]
  },
  {
    "path": "/v1/groups/:groupId/members",
    "methods": [
      "HEAD",
      "GET"
    ],
    "function": [
      "getGroupMembers"
    ]
  }
]

API

KoaMapper(url, routers)

  • url default is /metrics.
  • routers: array of router instance.

Readme

Keywords

Package Sidebar

Install

npm i koa-route-mapper

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • zfeng