0.9.2 • Published 6 years ago
koa-switch v0.9.2
koa-switch
an updated (and improved) alternative to koa-route
install
npm install --save koa-switchyarn add koa-switchuse
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
- Rather than path-params being exposed as an array of arguments to the callback (e.g.
thisis 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
thisanyhow
- This seems like it was a legacy/compatibility feature, as the first argument of the callback function was the same as
delis not available onexports