diff --git a/server/api/BaseApi.ts b/server/api/BaseApi.ts index 51672fb..d3b591b 100644 --- a/server/api/BaseApi.ts +++ b/server/api/BaseApi.ts @@ -8,6 +8,12 @@ export default abstract class BaseApi { this.onInit() } abstract onInit(): void + checkArgsMissing(args: {}, names: []) { + for (const k of names) + if (!(k in args)) + return true + return false + } registerEvent(name: CallMethod, func: EventCallbackFunction) { if (!name.startsWith(this.getName() + ".")) throw Error("注冊的事件應該與接口集合命名空間相匹配: " + name) ApiManager.addEventListener(name, func) diff --git a/server/api/UserApi.ts b/server/api/UserApi.ts index 3cdd70b..d7d8afd 100644 --- a/server/api/UserApi.ts +++ b/server/api/UserApi.ts @@ -5,7 +5,7 @@ export default class UserApi extends BaseApi { return "User" } override onInit(): void { - this.registerEvent("User.auth", () => { + this.registerEvent("User.auth", (args) => { return { msg: "", code: 200, diff --git a/server/types/EventCallbackFunction.ts b/server/types/EventCallbackFunction.ts index 59b857c..a1e8f29 100644 --- a/server/types/EventCallbackFunction.ts +++ b/server/types/EventCallbackFunction.ts @@ -1,5 +1,5 @@ import ApiCallbackMessage from "../api/ApiCallbackMessage.ts" -type EventCallbackFunction = (args: {}) => ApiCallbackMessage +type EventCallbackFunction = (args: { [key: string]: unknown }) => ApiCallbackMessage export default EventCallbackFunction