diff --git a/packages/repeater/src/bus/DefaultRepeaterBusFactory.spec.ts b/packages/repeater/src/bus/DefaultRepeaterBusFactory.spec.ts deleted file mode 100644 index 98659218..00000000 --- a/packages/repeater/src/bus/DefaultRepeaterBusFactory.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { DefaultRepeaterBusFactory } from './DefaultRepeaterBusFactory'; -import { RepeaterServer } from './RepeaterServer'; -import { RepeaterCommands } from './RepeaterCommands'; -import { DefaultRepeaterBus } from './DefaultRepeaterBus'; -import { Configuration, Logger } from '@sectester/core'; -import { instance, mock, reset } from 'ts-mockito'; - -describe('DefaultRepeaterBusFactory', () => { - const repeaterId = 'fooId'; - const mockedLogger = mock(); - const mockedConfiguration = mock(); - const mockedRepeaterServer = mock(); - const mockedRepeaterCommandHub = mock(); - - const configuration = instance(mockedConfiguration); - - let sut!: DefaultRepeaterBusFactory; - - beforeEach(() => { - sut = new DefaultRepeaterBusFactory( - repeaterId, - instance(mockedLogger), - configuration, - instance(mockedRepeaterServer), - instance(mockedRepeaterCommandHub) - ); - }); - - afterEach(() => { - reset( - mockedLogger, - mockedConfiguration, - mockedRepeaterServer, - mockedRepeaterCommandHub - ); - }); - - describe('create', () => { - it('should create', () => { - // act - const res = sut.create(); - - // assert - expect(res).toBeInstanceOf(DefaultRepeaterBus); - expect(res).toMatchObject({ - repeaterId - }); - }); - }); -}); diff --git a/packages/repeater/src/bus/DefaultRepeaterBusFactory.ts b/packages/repeater/src/bus/DefaultRepeaterBusFactory.ts deleted file mode 100644 index 75dfd6db..00000000 --- a/packages/repeater/src/bus/DefaultRepeaterBusFactory.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { RepeaterBus } from './RepeaterBus'; -import { DefaultRepeaterBus } from './DefaultRepeaterBus'; -import { RepeaterBusFactory } from './RepeaterBusFactory'; -import { RepeaterCommands } from './RepeaterCommands'; -import { RepeaterServer } from './RepeaterServer'; -import { RepeaterId } from '../lib/Repeater'; -import { Configuration, Logger } from '@sectester/core'; -import { inject, injectable } from 'tsyringe'; - -@injectable() -export class DefaultRepeaterBusFactory implements RepeaterBusFactory { - constructor( - @inject(RepeaterId) - private readonly repeaterId: RepeaterId, - private readonly logger: Logger, - private readonly configuration: Configuration, - @inject(RepeaterServer) private readonly repeaterServer: RepeaterServer, - @inject(RepeaterCommands) - private readonly repeaterCommands: RepeaterCommands - ) {} - - public create(): RepeaterBus { - this.logger.log( - 'Creating the repeater (%s)...', - this.configuration.version - ); - - return new DefaultRepeaterBus( - this.repeaterId, - this.logger, - this.repeaterServer, - this.repeaterCommands - ); - } -} diff --git a/packages/repeater/src/bus/RepeaterBus.ts b/packages/repeater/src/bus/RepeaterBus.ts deleted file mode 100644 index a3fd758f..00000000 --- a/packages/repeater/src/bus/RepeaterBus.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface RepeaterBus { - connect(): Promise; - close(): Promise; -} - -export const RepeaterBus: unique symbol = Symbol('RepeaterBus'); diff --git a/packages/repeater/src/bus/RepeaterBusFactory.ts b/packages/repeater/src/bus/RepeaterBusFactory.ts deleted file mode 100644 index a470caa6..00000000 --- a/packages/repeater/src/bus/RepeaterBusFactory.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RepeaterBus } from './RepeaterBus'; - -export interface RepeaterBusFactory { - create(): RepeaterBus; -} - -export const RepeaterBusFactory: unique symbol = Symbol('RepeaterBusFactory'); diff --git a/packages/repeater/src/bus/index.ts b/packages/repeater/src/bus/index.ts deleted file mode 100644 index 79611d29..00000000 --- a/packages/repeater/src/bus/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './DefaultRepeaterBusFactory'; -export * from './DefaultRepeaterCommands'; -export * from './DefaultRepeaterServer'; -export * from './RepeaterBus'; -export * from './RepeaterBusFactory'; -export * from './RepeaterCommands'; -export * from './RepeaterServer'; diff --git a/packages/repeater/src/bus/DefaultRepeaterBus.spec.ts b/packages/repeater/src/lib/DefaultRepeater.spec.ts similarity index 69% rename from packages/repeater/src/bus/DefaultRepeaterBus.spec.ts rename to packages/repeater/src/lib/DefaultRepeater.spec.ts index 1664e385..2ff5cec5 100644 --- a/packages/repeater/src/bus/DefaultRepeaterBus.spec.ts +++ b/packages/repeater/src/lib/DefaultRepeater.spec.ts @@ -1,4 +1,5 @@ -import { DefaultRepeaterBus } from './DefaultRepeaterBus'; +import { RunningStatus } from './Repeater'; +import { DefaultRepeater } from './DefaultRepeater'; import { Protocol } from '../models/Protocol'; import { Request, Response } from '../request-runner'; import { @@ -20,11 +21,11 @@ import { } from 'ts-mockito'; import { EventEmitter } from 'events'; -describe('DefaultRepeaterBus', () => { +describe('DefaultRepeater', () => { const RepeaterId = 'fooId'; let events!: EventEmitter; - let sut!: DefaultRepeaterBus; + let sut!: DefaultRepeater; const mockedRepeaterServer = mock(); const repeaterCommands = mock(); @@ -48,7 +49,7 @@ describe('DefaultRepeaterBus', () => { repeaterId: RepeaterId }); - sut = new DefaultRepeaterBus( + sut = new DefaultRepeater( RepeaterId, instance(mockedLogger), instance(mockedRepeaterServer), @@ -64,10 +65,10 @@ describe('DefaultRepeaterBus', () => { ) ); - describe('connect', () => { - it('should connect', async () => { + describe('start', () => { + it('should start', async () => { // act - await sut.connect(); + await sut.start(); // assert verify(mockedRepeaterServer.connect()).once(); @@ -78,23 +79,12 @@ describe('DefaultRepeaterBus', () => { ).once(); }); - it('should allow connect more than once', async () => { - // arrange - await sut.connect(); - - // act - const act = sut.connect(); - - // assert - await expect(act).resolves.not.toThrow(); - }); - it('should throw when underlying connect throws', async () => { // arrange when(mockedRepeaterServer.connect()).thenReject(new Error('foo')); // act - const act = () => sut.connect(); + const act = () => sut.start(); // assert await expect(act).rejects.toThrowError('foo'); @@ -107,27 +97,104 @@ describe('DefaultRepeaterBus', () => { ); // act - const act = () => sut.connect(); + const act = () => sut.start(); // assert await expect(act).rejects.toThrowError('foo'); }); + + it('should have RunningStatus.STARTING just after start() call', () => { + // act + void sut.start(); + + // assert + expect(sut.runningStatus).toBe(RunningStatus.STARTING); + }); + + it('should have RunningStatus.RUNNING after successful start()', async () => { + // act + await sut.start(); + + // assert + expect(sut.runningStatus).toBe(RunningStatus.RUNNING); + }); + + it('should throw an error on start() twice', async () => { + // arrange + await sut.start(); + + // act + const res = sut.start(); + + // assert + await expect(res).rejects.toThrow('Repeater is already active.'); + }); + + it('should be possible to start() after start() error', async () => { + // act + when(mockedRepeaterServer.connect()).thenReject().thenResolve(); + + // assert + await expect(sut.start()).rejects.toThrow(); + await expect(sut.start()).resolves.not.toThrow(); + }); }); - describe('close', () => { - it('should close', async () => { + describe('stop', () => { + it('should stop', async () => { + // arrange + await sut.start(); + // act - await sut.close(); + await sut.stop(); // assert verify(mockedRepeaterServer.disconnect()).once(); }); + + it('should have RunningStatus.OFF after start() and stop()', async () => { + // arrange + await sut.start(); + + // act + await sut.stop(); + + // assert + expect(sut.runningStatus).toBe(RunningStatus.OFF); + }); + + it('should do nothing on stop() without start()', async () => { + // act + await sut.stop(); + + // assert + expect(sut.runningStatus).toBe(RunningStatus.OFF); + }); + + it('should do nothing on second stop() call', async () => { + // arrange + await sut.start(); + await sut.stop(); + + // assert + await sut.stop(); + + // assert + expect(sut.runningStatus).toBe(RunningStatus.OFF); + }); + }); + + describe('runningStatus', () => { + it('should have RunningStatus.OFF initially', () => { + // assert + expect(sut.runningStatus).toBe(RunningStatus.OFF); + }); }); describe('events', () => { it(`should subscribe to ${RepeaterServerEvents.UPDATE_AVAILABLE}`, async () => { // arrange - await sut.connect(); + await sut.start(); // act events.emit(RepeaterServerEvents.UPDATE_AVAILABLE, { version: '1.0.0' }); @@ -159,7 +226,7 @@ describe('DefaultRepeaterBus', () => { }) ); - await sut.connect(); + await sut.start(); // act events.emit(RepeaterServerEvents.REQUEST, requestEvent); @@ -171,7 +238,7 @@ describe('DefaultRepeaterBus', () => { it(`should subscribe to ${RepeaterServerEvents.RECONNECT_ATTEMPT}`, async () => { // arrange - await sut.connect(); + await sut.start(); // act events.emit(RepeaterServerEvents.RECONNECT_ATTEMPT, { @@ -191,7 +258,7 @@ describe('DefaultRepeaterBus', () => { it(`should subscribe to ${RepeaterServerEvents.ERROR} and proceed on error`, async () => { // arrange - await sut.connect(); + await sut.start(); // act events.emit(RepeaterServerEvents.ERROR, { @@ -205,7 +272,7 @@ describe('DefaultRepeaterBus', () => { it(`should subscribe to ${RepeaterServerEvents.ERROR} and proceed on critical error`, async () => { // arrange - await sut.connect(); + await sut.start(); // act events.emit(RepeaterServerEvents.ERROR, { @@ -229,7 +296,7 @@ describe('DefaultRepeaterBus', () => { it(`should subscribe to ${RepeaterServerEvents.RECONNECTION_FAILED}`, async () => { // arrange const error = new Error('test error'); - await sut.connect(); + await sut.start(); // act events.emit(RepeaterServerEvents.RECONNECTION_FAILED, { @@ -243,7 +310,7 @@ describe('DefaultRepeaterBus', () => { it(`should subscribe to ${RepeaterServerEvents.RECONNECTION_SUCCEEDED}`, async () => { // arrange - await sut.connect(); + await sut.start(); // act events.emit(RepeaterServerEvents.RECONNECTION_SUCCEEDED); diff --git a/packages/repeater/src/bus/DefaultRepeaterBus.ts b/packages/repeater/src/lib/DefaultRepeater.ts similarity index 78% rename from packages/repeater/src/bus/DefaultRepeaterBus.ts rename to packages/repeater/src/lib/DefaultRepeater.ts index d62614f0..d2a42fe0 100644 --- a/packages/repeater/src/bus/DefaultRepeaterBus.ts +++ b/packages/repeater/src/lib/DefaultRepeater.ts @@ -1,4 +1,4 @@ -import { RepeaterBus } from './RepeaterBus'; +import { Repeater, RepeaterId, RunningStatus } from './Repeater'; import { RepeaterServer, RepeaterErrorCodes, @@ -9,37 +9,61 @@ import { RepeaterServerRequestEvent, RepeaterUpgradeAvailableEvent } from './RepeaterServer'; -import { RepeaterId } from '../lib/Repeater'; import { RepeaterCommands } from './RepeaterCommands'; import { Request } from '../request-runner/Request'; import { Logger } from '@sectester/core'; import chalk from 'chalk'; +import { inject, injectable, Lifecycle, scoped } from 'tsyringe'; -export class DefaultRepeaterBus implements RepeaterBus { - private repeaterRunning: boolean = false; +@scoped(Lifecycle.ContainerScoped) +@injectable() +export class DefaultRepeater implements Repeater { + private _runningStatus = RunningStatus.OFF; + + get runningStatus(): RunningStatus { + return this._runningStatus; + } constructor( - private readonly repeaterId: RepeaterId, + @inject(RepeaterId) + public readonly repeaterId: RepeaterId, private readonly logger: Logger, + @inject(RepeaterServer) private readonly repeaterServer: RepeaterServer, + @inject(RepeaterCommands) private readonly repeaterCommands: RepeaterCommands ) {} - public close() { - this.repeaterRunning = false; + public async start(): Promise { + if (this.runningStatus !== RunningStatus.OFF) { + throw new Error('Repeater is already active.'); + } + + this._runningStatus = RunningStatus.STARTING; - this.repeaterServer.disconnect(); + try { + await this.connect(); - return Promise.resolve(); + this._runningStatus = RunningStatus.RUNNING; + } catch (e) { + this._runningStatus = RunningStatus.OFF; + throw e; + } } - public async connect(): Promise { - if (this.repeaterRunning) { + public async stop(): Promise { + if (this.runningStatus !== RunningStatus.RUNNING) { return; } - this.repeaterRunning = true; + this._runningStatus = RunningStatus.OFF; + + this.repeaterServer.disconnect(); + + return Promise.resolve(); + } + private async connect(): Promise { this.logger.log('Connecting the Bridges'); this.subscribeDiagnosticEvents(); @@ -123,7 +147,7 @@ export class DefaultRepeaterBus implements RepeaterBus { message, remediation ); - this.close().catch(this.logger.error); + this.stop().catch(this.logger.error); } private upgradeAvailable = (event: RepeaterUpgradeAvailableEvent) => { @@ -149,7 +173,7 @@ export class DefaultRepeaterBus implements RepeaterBus { error }: RepeaterServerReconnectionFailedEvent) => { this.logger.error(error.message); - this.close().catch(this.logger.error); + this.stop().catch(this.logger.error); }; private requestReceived = async (event: RepeaterServerRequestEvent) => { diff --git a/packages/repeater/src/bus/DefaultRepeaterCommands.spec.ts b/packages/repeater/src/lib/DefaultRepeaterCommands.spec.ts similarity index 100% rename from packages/repeater/src/bus/DefaultRepeaterCommands.spec.ts rename to packages/repeater/src/lib/DefaultRepeaterCommands.spec.ts diff --git a/packages/repeater/src/bus/DefaultRepeaterCommands.ts b/packages/repeater/src/lib/DefaultRepeaterCommands.ts similarity index 100% rename from packages/repeater/src/bus/DefaultRepeaterCommands.ts rename to packages/repeater/src/lib/DefaultRepeaterCommands.ts diff --git a/packages/repeater/src/bus/DefaultRepeaterServer.spec.ts b/packages/repeater/src/lib/DefaultRepeaterServer.spec.ts similarity index 100% rename from packages/repeater/src/bus/DefaultRepeaterServer.spec.ts rename to packages/repeater/src/lib/DefaultRepeaterServer.spec.ts diff --git a/packages/repeater/src/bus/DefaultRepeaterServer.ts b/packages/repeater/src/lib/DefaultRepeaterServer.ts similarity index 100% rename from packages/repeater/src/bus/DefaultRepeaterServer.ts rename to packages/repeater/src/lib/DefaultRepeaterServer.ts diff --git a/packages/repeater/src/lib/Repeater.spec.ts b/packages/repeater/src/lib/Repeater.spec.ts deleted file mode 100644 index 41d73773..00000000 --- a/packages/repeater/src/lib/Repeater.spec.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { Repeater, RunningStatus } from './Repeater'; -import { RepeaterBus } from '../bus'; -import { instance, mock, reset, verify, when } from 'ts-mockito'; - -describe('Repeater', () => { - const repeaterId = 'fooId'; - - let repeater!: Repeater; - const mockedRepeaterBus = mock(); - - const createRepeater = () => - new Repeater(repeaterId, instance(mockedRepeaterBus)); - - beforeEach(() => { - repeater = createRepeater(); - }); - - afterEach(() => reset(mockedRepeaterBus)); - - describe('start', () => { - it('should start', async () => { - // act - await repeater.start(); - - // assert - verify(mockedRepeaterBus.connect()).once(); - }); - - it('should have RunningStatus.STARTING just after start() call', () => { - // act - void repeater.start(); - - // assert - expect(repeater.runningStatus).toBe(RunningStatus.STARTING); - }); - - it('should have RunningStatus.RUNNING after successful start()', async () => { - // act - await repeater.start(); - - // assert - expect(repeater.runningStatus).toBe(RunningStatus.RUNNING); - }); - - it('should throw an error on start() twice', async () => { - // arrange - await repeater.start(); - - // act - const res = repeater.start(); - - // assert - await expect(res).rejects.toThrow('Repeater is already active.'); - }); - - it('should be possible to start() after start() error', async () => { - // act - when(mockedRepeaterBus.connect()).thenReject().thenResolve(); - - // assert - await expect(repeater.start()).rejects.toThrow(); - await expect(repeater.start()).resolves.not.toThrow(); - }); - }); - - describe('stop', () => { - it('should stop', async () => { - // arrange - await repeater.start(); - - // act - await repeater.stop(); - - // assert - verify(mockedRepeaterBus.close()).once(); - }); - - it('should have RunningStatus.OFF after start() and stop()', async () => { - // arrange - await repeater.start(); - - // act - await repeater.stop(); - - // assert - expect(repeater.runningStatus).toBe(RunningStatus.OFF); - }); - - it('should do nothing on stop() without start()', async () => { - // act - await repeater.stop(); - - // assert - expect(repeater.runningStatus).toBe(RunningStatus.OFF); - }); - - it('should do nothing on second stop() call', async () => { - // arrange - await repeater.start(); - await repeater.stop(); - - // assert - await repeater.stop(); - - // assert - expect(repeater.runningStatus).toBe(RunningStatus.OFF); - }); - }); - - describe('runningStatus', () => { - it('should have RunningStatus.OFF initially', () => { - // assert - expect(repeater.runningStatus).toBe(RunningStatus.OFF); - }); - }); -}); diff --git a/packages/repeater/src/lib/Repeater.ts b/packages/repeater/src/lib/Repeater.ts index eed8bd3c..a497be0f 100644 --- a/packages/repeater/src/lib/Repeater.ts +++ b/packages/repeater/src/lib/Repeater.ts @@ -1,5 +1,3 @@ -import { RepeaterBus } from '../bus'; - export enum RunningStatus { OFF, STARTING, @@ -9,42 +7,11 @@ export enum RunningStatus { export type RepeaterId = string; export const RepeaterId = Symbol('RepeaterId'); -export class Repeater { - private _runningStatus = RunningStatus.OFF; - - get runningStatus(): RunningStatus { - return this._runningStatus; - } - - constructor( - public readonly repeaterId: RepeaterId, - private readonly bus: RepeaterBus - ) {} - - public async start(): Promise { - if (this.runningStatus !== RunningStatus.OFF) { - throw new Error('Repeater is already active.'); - } - - this._runningStatus = RunningStatus.STARTING; - - try { - await this.bus.connect(); - - this._runningStatus = RunningStatus.RUNNING; - } catch (e) { - this._runningStatus = RunningStatus.OFF; - throw e; - } - } - - public async stop(): Promise { - if (this.runningStatus !== RunningStatus.RUNNING) { - return; - } - - this._runningStatus = RunningStatus.OFF; - - await this.bus.close(); - } +export interface Repeater { + readonly repeaterId: RepeaterId; + readonly runningStatus: RunningStatus; + start(): Promise; + stop(): Promise; } + +export const Repeater: unique symbol = Symbol('Repeater'); diff --git a/packages/repeater/src/bus/RepeaterCommands.ts b/packages/repeater/src/lib/RepeaterCommands.ts similarity index 100% rename from packages/repeater/src/bus/RepeaterCommands.ts rename to packages/repeater/src/lib/RepeaterCommands.ts diff --git a/packages/repeater/src/lib/RepeaterFactory.spec.ts b/packages/repeater/src/lib/RepeaterFactory.spec.ts index db194575..19a51435 100644 --- a/packages/repeater/src/lib/RepeaterFactory.spec.ts +++ b/packages/repeater/src/lib/RepeaterFactory.spec.ts @@ -1,6 +1,4 @@ import { RepeaterFactory } from './RepeaterFactory'; -import { RepeaterBus } from '../bus/RepeaterBus'; -import { RepeaterBusFactory } from '../bus/RepeaterBusFactory'; import { HttpRequestRunner, RequestRunner, @@ -49,8 +47,6 @@ describe('RepeaterFactory', () => { const mockedContainer = mock(); const mockedChildContainer = mock(); const mockedConfiguration = mock(); - const mockedRepeaterBus = mock(); - const mockedRepeaterBusFactory = mock(); const mockedRepeaterManager = mock(); const configuration = instance(mockedConfiguration); @@ -64,32 +60,20 @@ describe('RepeaterFactory', () => { instance(mockedChildContainer) ); - when( - mockedChildContainer.resolve(RepeaterBusFactory) - ).thenReturn(instance(mockedRepeaterBusFactory)); - when( mockedContainer.resolve(RepeatersManager) ).thenReturn(instance(mockedRepeaterManager)); - when(mockedRepeaterBusFactory.create()).thenReturn( - instance(mockedRepeaterBus) - ); - when(mockedRepeaterManager.createRepeater(anything())).thenResolve({ repeaterId }); }); afterEach(() => { - reset< - DependencyContainer | Configuration | RepeaterBus | RepeaterBusFactory - >( + reset( mockedContainer, mockedChildContainer, - mockedConfiguration, - mockedRepeaterBus, - mockedRepeaterBusFactory + mockedConfiguration ); }); @@ -99,10 +83,10 @@ describe('RepeaterFactory', () => { const factory = new RepeaterFactory(configuration); // act - const res = await factory.createRepeater(); + await factory.createRepeater(); // assert - expect(res).toBeInstanceOf(Repeater); + verify(mockedChildContainer.resolve(Repeater)).once(); }); it('should register custom request runner options', async () => { diff --git a/packages/repeater/src/lib/RepeaterFactory.ts b/packages/repeater/src/lib/RepeaterFactory.ts index 4d9d9915..d081ccf6 100644 --- a/packages/repeater/src/lib/RepeaterFactory.ts +++ b/packages/repeater/src/lib/RepeaterFactory.ts @@ -2,7 +2,6 @@ import { Repeater, RepeaterId } from './Repeater'; import { RequestRunner, RequestRunnerOptions } from '../request-runner'; import { RepeatersManager } from '../api'; import { RepeaterOptions } from './RepeaterOptions'; -import { RepeaterBusFactory } from '../bus/RepeaterBusFactory'; import { Configuration } from '@sectester/core'; import { v4 as uuidv4 } from 'uuid'; import { DependencyContainer, injectable, Lifecycle } from 'tsyringe'; @@ -46,10 +45,7 @@ export class RepeaterFactory { this.registerRequestRunnerOptions(container, requestRunnerOptions); this.registerRequestRunners(container, requestRunners ?? []); - const busFactory = - container.resolve(RepeaterBusFactory); - - return new Repeater(repeaterId, busFactory.create()); + return container.resolve(Repeater); } private registerRequestRunners( diff --git a/packages/repeater/src/bus/RepeaterServer.ts b/packages/repeater/src/lib/RepeaterServer.ts similarity index 100% rename from packages/repeater/src/bus/RepeaterServer.ts rename to packages/repeater/src/lib/RepeaterServer.ts diff --git a/packages/repeater/src/lib/index.ts b/packages/repeater/src/lib/index.ts index 4d4794bb..5e98fa4f 100644 --- a/packages/repeater/src/lib/index.ts +++ b/packages/repeater/src/lib/index.ts @@ -1,5 +1,9 @@ -export { Repeater, RunningStatus, RepeaterId } from './Repeater'; -export { RepeaterFactory } from './RepeaterFactory'; -export { RepeaterOptions } from './RepeaterOptions'; -export { RepeaterRequestRunnerOptions } from './RepeaterRequestRunnerOptions'; -export { RepeaterStatus } from '../models/RepeaterStatus'; +export * from './Repeater'; +export * from './RepeaterFactory'; +export * from './RepeaterOptions'; +export * from './RepeaterRequestRunnerOptions'; +export * from './DefaultRepeater'; +export * from './DefaultRepeaterCommands'; +export * from './DefaultRepeaterServer'; +export * from './RepeaterCommands'; +export * from './RepeaterServer'; diff --git a/packages/repeater/src/register.ts b/packages/repeater/src/register.ts index 315af601..5a4009e5 100644 --- a/packages/repeater/src/register.ts +++ b/packages/repeater/src/register.ts @@ -1,13 +1,14 @@ -import { RepeaterFactory, RepeaterId } from './lib'; import { - DefaultRepeaterBusFactory, + RepeaterFactory, + RepeaterId, DefaultRepeaterCommands, DefaultRepeaterServer, + DefaultRepeater, DefaultRepeaterServerOptions, - RepeaterBusFactory, RepeaterCommands, - RepeaterServer -} from './bus'; + RepeaterServer, + Repeater +} from './lib'; import { HttpRequestRunner, RequestRunner, @@ -113,8 +114,8 @@ container.register(DefaultRepeaterServerOptions, { } }); +container.register(Repeater, { useClass: DefaultRepeater }); container.register(ProxyFactory, { useClass: DefaultProxyFactory }); container.register(RepeaterServer, { useClass: DefaultRepeaterServer }); container.register(RepeaterCommands, { useClass: DefaultRepeaterCommands }); -container.register(RepeaterBusFactory, { useClass: DefaultRepeaterBusFactory }); container.register(RepeatersManager, { useClass: DefaultRepeatersManager });