mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
framework: mixin: support callback style
This commit is contained in:
3 files changed
+9
-8
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user