https://github.com/tdzl2003/koa-router-meta
Add meta property and auto-doc for koa-router
https://github.com/tdzl2003/koa-router-meta
Last synced: 4 months ago
JSON representation
Add meta property and auto-doc for koa-router
- Host: GitHub
- URL: https://github.com/tdzl2003/koa-router-meta
- Owner: tdzl2003
- Created: 2017-07-22T04:52:13.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-17T09:14:28.000Z (over 7 years ago)
- Last Synced: 2025-05-09T06:11:29.471Z (5 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Koa-Router-Meta
Adds validate and auto document for koa-router.
Simple usage:
```javascript
const { regexp } = require('koa-router-meta');
const router = require('koa-router')();if (__DEV__) {
// This line add auto document feature on development mode.
router.registerMetaRoute();
}router.get({
path: '/hello',
comment: '这是一个示例描述',
validate: {
query: {
who: regexp("您的姓名", /^.+$/).required,
},
},
mockResponse: 'This is a mock response.',
handler: async ctx => {
ctx.body = "world.";
},
});
```So visit `http://YourDevelopmentServer/user/_doc.html` for auto document.