framework: mixin: support callback style

This commit is contained in:
undefined committed 2025-03-12 15:49:04 +08:00
1 parent 51c3c4f30f
commit af1b12deed
3 files changed
+9 -8

No files matched your search

+3 -3
View File
@@ -222,15 +222,15 @@ export async function apply(ctx: Context) {
}
},
});
server.wsHandlerMixin({
server.wsHandlerMixin((s) => ({
async onerror(err: HydroError) {
if (![NotFoundError, PrivilegeError, PermissionError].some((i) => err instanceof i) || this.user?._id !== 0) {
logger.error(`Path:${this.request.path}, User:${this.user?._id}(${this.user?.uname})`);
logger.error(err);
}
await super.onerror(err);
await s.onerror(err);
},
});
}));
on('handler/create', async (h) => {
h.user = h.context.HydroContext.user as any;
+1 -1
View File
@@ -74,7 +74,7 @@ export class ConfigService extends Service {
await this.saveConfig(newConfig);
}
requestConfig<T, S>(s: Schema<T, S>, dynamic = true): ReturnType<Schema<T, S>> {
requestConfig<T, S>(s: Schema<T, S>, dynamic = true): S {
if (dynamic) {
this.ctx.effect(() => {
this.settings.push(s);