@zcorky/koa-validate
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

koa-validate

NPM version Coverage Status Dependencies Build Status license issues

response time header for Koa.

Install

$ npm install @zcorky/koa-validate

Usage

// See more in test
import * as bodyParser from 'koa-body';
import onerror from '@zcorky/onerror';
import validate from '@zcorky/koa-validate';
import * as router from '@zcorky/koa-router';

import * as Koa from 'koa';
const app = new Koa();

app.use(onerror());
app.use(bodyParse());
app.use(validate());

app.use(router.post('/', (ctx, next) => {
  ctx.validate({
    name: 'string',
    age: 'int',
  });
}, ctx => {
  ctx.body = ctx.request.body;
}));

app.listen(8000, '0.0.0.0', () => {
  console.log('koa server start at port: 8000');
});

Related

/@zcorky/koa-validate/

    Package Sidebar

    Install

    npm i @zcorky/koa-validate

    Weekly Downloads

    0

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    5.23 kB

    Total Files

    5

    Last publish

    Collaborators

    • uniquecolesmith