1- import { join , resolve } from 'node:path' ;
2- import { fileURLToPath } from 'node:url' ;
1+ import { join } from 'node:path' ;
32
43import {
54 DynamicModule ,
65 ForwardReference ,
76 Logger ,
8- MiddlewareConsumer ,
97 Module ,
10- NestModule ,
118} from '@nestjs/common' ;
129import { ScheduleModule } from '@nestjs/schedule' ;
1310import { ServeStaticModule } from '@nestjs/serve-static' ;
@@ -19,7 +16,7 @@ import { ADD_ENABLED_FEATURES, ServerConfigModule } from './core/config';
1916import { DocModule } from './core/doc' ;
2017import { FeatureModule } from './core/features' ;
2118import { QuotaModule } from './core/quota' ;
22- import { CustomSetupModule , SetupMiddleware } from './core/setup' ;
19+ import { CustomSetupModule } from './core/setup' ;
2320import { StorageModule } from './core/storage' ;
2421import { SyncModule } from './core/sync' ;
2522import { UserModule } from './core/user' ;
@@ -138,26 +135,16 @@ export class AppModuleBuilder {
138135 }
139136
140137 compile ( ) {
141- const configure = ( consumer : MiddlewareConsumer ) => {
142- if ( this . config . isSelfhosted ) {
143- consumer . apply ( SetupMiddleware ) . forRoutes ( '*' ) ;
144- }
145- } ;
146-
147138 @Module ( {
148139 imports : this . modules ,
149140 controllers : this . config . isSelfhosted ? [ ] : [ AppController ] ,
150141 } )
151- class AppModule implements NestModule {
152- configure = configure ;
153- }
142+ class AppModule { }
154143
155144 return AppModule ;
156145 }
157146}
158147
159- const pwd = resolve ( fileURLToPath ( import . meta. url ) , '../../' ) ;
160-
161148function buildAppModule ( ) {
162149 AFFiNE = mergeConfigOverride ( AFFiNE ) ;
163150 const factor = new AppModuleBuilder ( AFFiNE ) ;
@@ -192,12 +179,12 @@ function buildAppModule() {
192179 config => config . isSelfhosted ,
193180 CustomSetupModule ,
194181 ServeStaticModule . forRoot ( {
195- rootPath : join ( pwd , 'static ', 'admin ' ) ,
196- renderPath : / ^ \/ a d m i n \/ ? / ,
182+ rootPath : join ( '/app ', 'static ' ) ,
183+ exclude : [ '/ admin*' ] ,
197184 } ) ,
198185 ServeStaticModule . forRoot ( {
199- rootPath : join ( pwd , 'static' ) ,
200- renderPath : '* ' ,
186+ rootPath : join ( '/app' , 'static' , 'admin ') ,
187+ serveRoot : '/admin ' ,
201188 } )
202189 ) ;
203190
0 commit comments