feat(server): use nestjs events to validate config (#7986)
* use events for config validation * chore: better types * add unit tests --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { AssetResponseDto, ReleaseNotification, ServerVersionResponseDto } from '@app/domain';
|
||||
import { SystemConfig } from '@app/infra/entities';
|
||||
|
||||
export const ICommunicationRepository = 'ICommunicationRepository';
|
||||
|
||||
@@ -21,6 +22,14 @@ export enum ServerEvent {
|
||||
CONFIG_UPDATE = 'config:update',
|
||||
}
|
||||
|
||||
export enum InternalEvent {
|
||||
VALIDATE_CONFIG = 'validate_config',
|
||||
}
|
||||
|
||||
export interface InternalEventMap {
|
||||
[InternalEvent.VALIDATE_CONFIG]: { newConfig: SystemConfig; oldConfig: SystemConfig };
|
||||
}
|
||||
|
||||
export interface ClientEventMap {
|
||||
[ClientEvent.UPLOAD_SUCCESS]: AssetResponseDto;
|
||||
[ClientEvent.USER_DELETE]: string;
|
||||
@@ -45,4 +54,6 @@ export interface ICommunicationRepository {
|
||||
on(event: 'connect', callback: OnConnectCallback): void;
|
||||
on(event: ServerEvent, callback: OnServerEventCallback): void;
|
||||
sendServerEvent(event: ServerEvent): void;
|
||||
emit<E extends keyof InternalEventMap>(event: E, data: InternalEventMap[E]): boolean;
|
||||
emitAsync<E extends keyof InternalEventMap>(event: E, data: InternalEventMap[E]): Promise<any>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user