2.0.0 • Published 8 years ago
auk-params v2.0.0
auk-params
import Koa from 'koa';
import params from 'auk-params';
const app = new Koa();
params(app);
index(ctx) {
const name = ctx.params.string('name').notEmpty().value;
ctx.body = this.t('Hello %s!', ctx.params.isValid() ? name : 'World');
},
something(ctx) {
// throw a 404 if the param was not found
const name = ctx.validParams.string('name').notEmpty().value;
ctx.body = this.t('Hello %s!', name);
},