feat: 设置默认的context

This commit is contained in:
2024-11-12 11:19:11 +08:00
parent 303c579e92
commit 780d744a16
3 changed files with 9 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ export class App<T = {}> {
const router = opts?.router || new QueryRouter();
const server = opts?.server || new Server(opts?.serverOptions || {});
server.setHandle(router.getHandle(router, opts?.routerHandle, opts?.routerContext));
router.setContext(opts?.routerContext);
this.router = router;
this.server = server;
if (opts?.io) {
@@ -81,7 +81,7 @@ export class App<T = {}> {
}
async call(message: { path: string; key: string; payload?: any }, ctx?: RouteContext & { [key: string]: any }) {
const router = this.router;
return await router.parse(message, ctx);
return await router.call(message, ctx);
}
exportRoutes() {
return this.router.exportRoutes();
@@ -97,4 +97,3 @@ export class App<T = {}> {
throw new CustomError(...args);
}
}