mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
使用 @param 验证接口
This commit is contained in:
1 parent
4e85b696c0
commit
19cf1a5304
22 files changed
+657
-393
No files matched your search
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user