使用 @param 验证接口

This commit is contained in:
undefined committed 2020-07-10 22:54:26 +08:00
1 parent 4e85b696c0
commit 19cf1a5304
22 files changed
+657 -393

No files matched your search

+6 -2
View File
@@ -1,8 +1,12 @@
import { NotFoundError } from '../error';
import { Route, Handler } from '../service/server';
import {
Route, Handler, Types, param,
} from '../service/server';
class WikiHandler extends Handler {
async get({ category = 'wiki', page }) {
@param('category', Types.String, true)
@param('page', Types.String)
async get(domainId: string, category = 'wiki', page: string) {
if (!global.Hydro.wiki[category]) throw new NotFoundError(category);
if (!global.Hydro.wiki[category][page]) throw new NotFoundError(category, page);
const contents = global.Hydro.wiki[category][page];