mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
feat: validator decorator
This commit is contained in:
1 parent
ba03d7a7bf
commit
4e85b696c0
23 files changed
+313
-180
No files matched your search
@@ -8,6 +8,7 @@ import * as record from '../model/record';
|
||||
import {
|
||||
Route, Connection, Handler, ConnectionHandler,
|
||||
} from '../service/server';
|
||||
import { validate } from '../lib/validator';
|
||||
import * as hpm from '../lib/hpm';
|
||||
|
||||
function set(key, value) {
|
||||
@@ -103,7 +104,9 @@ class SystemScriptHandler extends SystemHandler {
|
||||
}
|
||||
|
||||
async post({ domainId, id, args = '{}' }) {
|
||||
if (!global.Hydro.script[id]) throw new ValidationError('id');
|
||||
args = JSON.parse(args);
|
||||
validate(global.Hydro.script[id].validate, args);
|
||||
const rid = await record.add(domainId, {
|
||||
pid: id,
|
||||
uid: this.user._id,
|
||||
@@ -161,7 +164,7 @@ class SystemSettingHandler extends SystemHandler {
|
||||
}
|
||||
}
|
||||
|
||||
async post(args) {
|
||||
async post(args: any) {
|
||||
const tasks = [];
|
||||
for (const key in args) {
|
||||
if (typeof args[key] === 'object') {
|
||||
|
||||
Reference in new issue
Block a user