koa-rest-version
parse rest api version config, support two format:
API
options.typeKey
the type query key, default: _type
options.override
override the original path
const Koa = require('koa');
const version = require('version');
const app = new Koa();
app.use(version({
typeKey: 'type',
override: true,
}));
app.use(ctx => {
console.info(ctx.acceptConfig);
});
app.listen();
const Koa = require('koa');
const version = require('version');
const app = new Koa();
app.use(version());
app.use(ctx => {
console.info(ctx.acceptConfig);
});
app.listen();
const Koa = require('koa');
const version = require('version');
const app = new Koa();
app.use(version('content-type'));
app.use(ctx => {
console.info(ctx.acceptConfig);
});
app.listen();
License
MIT