Browse Source

fix dynamic importing code

Yuki Takei 4 tháng trước cách đây
mục cha
commit
09ae067cee
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      apps/app/src/server/crowi/index.ts

+ 6 - 2
apps/app/src/server/crowi/index.ts

@@ -658,8 +658,12 @@ class Crowi {
    * !! this must be at last because it includes '/*' route !!
    */
   async setupRoutesAtLast(): Promise<void> {
-    const routes = await import('../routes');
-    routes.default(this, this.express);
+    type RoutesSetup = (crowi: Crowi, app: Express) => void;
+    // CommonJS modules are always wrapped in { default } when dynamically imported
+    const { default: setupRoutes } = (await import('../routes')) as unknown as {
+      default: RoutesSetup;
+    };
+    setupRoutes(this, this.express);
   }
 
   /**