File
Readonly
auth
|
Type : literal type
|
Decorators :
@IsObject({groups: undefined})
|
|
Readonly
databaseName
|
Type : string
|
Decorators :
@IsString({always: true})
|
|
Readonly
host
|
Type : string
|
Decorators :
@IsString({always: true})
|
|
Readonly
Optional
maxRetries
|
Type : number
|
Decorators :
@IsOptional({always: true}) @IsNumber({}, {always: true}) @Min(0, {always: true})
|
|
Readonly
port
|
Type : number
|
Decorators :
@Min(0, {always: true})
|
|
Readonly
Optional
reconnectTimeout
|
Type : number
|
Decorators :
@IsOptional({always: true}) @IsNumber({}, {always: true}) @Min(0, {always: true})
|
|
Readonly
secret
|
Type : string
|
Decorators :
@IsString({groups: undefined})
|
|
import { IsNumber, IsObject, IsOptional, IsString, Min } from 'class-validator';
export enum DatabaseConfigurationValidationGroup {
ALL = 'all',
}
export class DatabaseConfiguration {
@IsString({ always: true })
readonly host!: string;
@Min(0, { always: true })
readonly port!: number;
@IsString({ always: true })
readonly databaseName!: string;
@IsOptional({ always: true })
@IsNumber({}, { always: true })
@Min(0, { always: true })
readonly maxRetries?: number;
@IsOptional({ always: true })
@IsNumber({}, { always: true })
@Min(0, { always: true })
readonly reconnectTimeout?: number;
@IsString({ groups: [DatabaseConfigurationValidationGroup.ALL] })
readonly secret!: string;
@IsObject({ groups: [DatabaseConfigurationValidationGroup.ALL] })
readonly auth!: { user: string; pass: string };
}
export interface DatabaseConnectionOptions {
readonly host: string;
readonly port: number;
readonly dbName: string;
readonly user: string;
readonly password: string;
}