koa-switch

0.9.2 • Public • Published

koa-switch

an updated (and improved) alternative to koa-route

install

npm install --save koa-switch
yarn add koa-switch

use

See example.js.

key differences

  • Full support for named path params
    • Rather than path-params being exposed as an array of arguments to the callback (e.g. (ctx, foo, bar, next) => {}), they're now exposed as one object with parameters correlating to the specified path-params (e.g. (ctx, params, next) => {})
    • Documentation for path options can be found at path-to-regexp
  • this is unavailable in the route callback
    • This seems like it was a legacy/compatibility feature, as the first argument of the callback function was the same as this anyhow
  • del is not available on exports

Readme

Keywords

Package Sidebar

Install

npm i koa-switch

Weekly Downloads

1

Version

0.9.2

License

MIT

Unpacked Size

3.07 kB

Total Files

4

Last publish

Collaborators

  • pearofducks