mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 13:17:10 +08:00
chore(server): split module
This commit is contained in:
@@ -3,6 +3,7 @@ import { getCurrentUserQuery } from '@affine/graphql';
|
|||||||
import { JobExecutor } from '../../../base/job/queue/executor';
|
import { JobExecutor } from '../../../base/job/queue/executor';
|
||||||
import { JobHandlerScanner } from '../../../base/job/queue/scanner';
|
import { JobHandlerScanner } from '../../../base/job/queue/scanner';
|
||||||
import { DatabaseDocReader, DocReader } from '../../../core/doc';
|
import { DatabaseDocReader, DocReader } from '../../../core/doc';
|
||||||
|
import { RealtimeGateway } from '../../../core/realtime/gateway';
|
||||||
import { createApp } from '../create-app';
|
import { createApp } from '../create-app';
|
||||||
import { e2e } from '../test';
|
import { e2e } from '../test';
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ e2e('should init worker service', async t => {
|
|||||||
const res = await app.GET('/info').expect(200);
|
const res = await app.GET('/info').expect(200);
|
||||||
t.is(res.body.flavor, 'worker');
|
t.is(res.body.flavor, 'worker');
|
||||||
t.truthy(app.get(JobHandlerScanner).getHandler('indexer.indexDoc'));
|
t.truthy(app.get(JobHandlerScanner).getHandler('indexer.indexDoc'));
|
||||||
|
t.throws(() => app.get(RealtimeGateway));
|
||||||
|
|
||||||
await t.throwsAsync(app.gql({ query: getCurrentUserQuery }));
|
await t.throwsAsync(app.gql({ query: getCurrentUserQuery }));
|
||||||
await app.PUT('/api/storage/upload').expect(404);
|
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 });
|
const user = await app.gql({ query: getCurrentUserQuery });
|
||||||
t.is(user.currentUser, null);
|
t.is(user.currentUser, null);
|
||||||
|
t.truthy(app.get(RealtimeGateway));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import { NotificationModule } from './core/notification';
|
|||||||
import { PermissionModule } from './core/permission';
|
import { PermissionModule } from './core/permission';
|
||||||
import { QueueDashboardModule } from './core/queue-dashboard';
|
import { QueueDashboardModule } from './core/queue-dashboard';
|
||||||
import { QuotaModule } from './core/quota';
|
import { QuotaModule } from './core/quota';
|
||||||
import { RealtimeModule } from './core/realtime';
|
import { RealtimeGatewayModule, RealtimeModule } from './core/realtime';
|
||||||
import { SelfhostModule } from './core/selfhost';
|
import { SelfhostModule } from './core/selfhost';
|
||||||
import { StaticFileModule } from './core/static-files';
|
import { StaticFileModule } from './core/static-files';
|
||||||
import { StorageApiModule, StorageWorkerModule } from './core/storage';
|
import { StorageApiModule, StorageWorkerModule } from './core/storage';
|
||||||
@@ -167,6 +167,7 @@ export function buildAppModule(env: Env) {
|
|||||||
factor
|
factor
|
||||||
// basic
|
// basic
|
||||||
.use(...FunctionalityModules)
|
.use(...FunctionalityModules)
|
||||||
|
.useIf(() => !workerOnly, RealtimeGatewayModule)
|
||||||
|
|
||||||
// online roles publish indexer events; only the worker registers consumers
|
// online roles publish indexer events; only the worker registers consumers
|
||||||
.useIf(() => env.isApi || env.isFrontend, IndexerModule)
|
.useIf(() => env.isApi || env.isFrontend, IndexerModule)
|
||||||
|
|||||||
@@ -7,16 +7,17 @@ import { RealtimeRegistry } from './registry';
|
|||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [RealtimeRegistry, RealtimePublisher],
|
||||||
RealtimeRegistry,
|
|
||||||
RealtimePublisher,
|
|
||||||
RealtimeGateway,
|
|
||||||
RealtimeRegistryCompletenessChecker,
|
|
||||||
],
|
|
||||||
exports: [RealtimeRegistry, RealtimePublisher],
|
exports: [RealtimeRegistry, RealtimePublisher],
|
||||||
})
|
})
|
||||||
export class RealtimeModule {}
|
export class RealtimeModule {}
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [RealtimeModule],
|
||||||
|
providers: [RealtimeGateway, RealtimeRegistryCompletenessChecker],
|
||||||
|
})
|
||||||
|
export class RealtimeGatewayModule {}
|
||||||
|
|
||||||
export { RealtimeRegistryCompletenessChecker } from './completeness';
|
export { RealtimeRegistryCompletenessChecker } from './completeness';
|
||||||
export { registerRealtimeLiveQuery } from './provider';
|
export { registerRealtimeLiveQuery } from './provider';
|
||||||
export { RealtimePublisher } from './publisher';
|
export { RealtimePublisher } from './publisher';
|
||||||
|
|||||||
Reference in New Issue
Block a user