router-schema
router-schema
is a request router schema validator based on joi in node.js, support express.js
and koa.js@2.x
with koa-router
.
Installation
npm install router-schema joi -S
Example
Create schema.js
:
const Joi = ; const schema = 'GET /foo/bar': query: hello: Joi body: world: Joi '/bar/foo': query: hello: Joi body: world: Joi ; moduleexports = schema;
Koa.js@2.x
'use strict'; const Koa = ;const Router = ;const bodyParser = ;const KoaRouterSchema = ;const schema = ; const routerSchema = ;const app = ;const router = routerSchema; // handle the errorsapp; app;app;app; app;
Express.js
'use strict'; const express = ;const bodyParser = ;const ExpressRouterSchema = ;const schema = ; const app = ; const routerSchema = express;const router = routerSchema; app;app;app; app; // handle errorsapp; app;
API
todo
Schema
todo
ChangeLog
License
MIT