chore(server): split module

This commit is contained in:
DarkSky
2026-08-22 08:05:46 +08:00
parent 478a1a0f30
commit a8eef53966
3 changed files with 12 additions and 7 deletions
@@ -3,6 +3,7 @@ import { getCurrentUserQuery } from '@affine/graphql';
import { JobExecutor } from '../../../base/job/queue/executor';
import { JobHandlerScanner } from '../../../base/job/queue/scanner';
import { DatabaseDocReader, DocReader } from '../../../core/doc';
import { RealtimeGateway } from '../../../core/realtime/gateway';
import { createApp } from '../create-app';
import { e2e } from '../test';
@@ -43,6 +44,7 @@ e2e('should init worker service', async t => {
const res = await app.GET('/info').expect(200);
t.is(res.body.flavor, 'worker');
t.truthy(app.get(JobHandlerScanner).getHandler('indexer.indexDoc'));
t.throws(() => app.get(RealtimeGateway));
await t.throwsAsync(app.gql({ query: getCurrentUserQuery }));
await app.PUT('/api/storage/upload').expect(404);
@@ -65,6 +67,7 @@ e2e('should init graphql service', async t => {
const user = await app.gql({ query: getCurrentUserQuery });
t.is(user.currentUser, null);
t.truthy(app.get(RealtimeGateway));
});
});
+2 -1
View File
@@ -45,7 +45,7 @@ import { NotificationModule } from './core/notification';
import { PermissionModule } from './core/permission';
import { QueueDashboardModule } from './core/queue-dashboard';
import { QuotaModule } from './core/quota';
import { RealtimeModule } from './core/realtime';
import { RealtimeGatewayModule, RealtimeModule } from './core/realtime';
import { SelfhostModule } from './core/selfhost';
import { StaticFileModule } from './core/static-files';
import { StorageApiModule, StorageWorkerModule } from './core/storage';
@@ -167,6 +167,7 @@ export function buildAppModule(env: Env) {
factor
// basic
.use(...FunctionalityModules)
.useIf(() => !workerOnly, RealtimeGatewayModule)
// online roles publish indexer events; only the worker registers consumers
.useIf(() => env.isApi || env.isFrontend, IndexerModule)
@@ -7,16 +7,17 @@ import { RealtimeRegistry } from './registry';
@Global()
@Module({
providers: [
RealtimeRegistry,
RealtimePublisher,
RealtimeGateway,
RealtimeRegistryCompletenessChecker,
],
providers: [RealtimeRegistry, RealtimePublisher],
exports: [RealtimeRegistry, RealtimePublisher],
})
export class RealtimeModule {}
@Module({
imports: [RealtimeModule],
providers: [RealtimeGateway, RealtimeRegistryCompletenessChecker],
})
export class RealtimeGatewayModule {}
export { RealtimeRegistryCompletenessChecker } from './completeness';
export { registerRealtimeLiveQuery } from './provider';
export { RealtimePublisher } from './publisher';