cleanup
This commit is contained in:
parent
c353ddbe01
commit
ce9e2df67c
310 changed files with 2550 additions and 36861 deletions
|
|
@ -14,6 +14,16 @@ import { HandlerScanner } from '../scanner';
|
|||
import { ServiceLifecycleManager } from '../utils/lifecycle';
|
||||
import type { ContainerBuildOptions, ServiceDefinitions } from './types';
|
||||
|
||||
function extractMongoDatabaseFromUri(uri?: string): string | undefined {
|
||||
if (!uri) return undefined;
|
||||
try {
|
||||
const db = new URL(uri).pathname.replace(/^\/+/, '').split('/')[0];
|
||||
return db || undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function getInfluxPort(config: { influxPort?: number; ilpPort?: number }): number {
|
||||
return config.influxPort ?? config.ilpPort ?? 9009;
|
||||
}
|
||||
|
|
@ -133,6 +143,16 @@ export class ServiceContainerBuilder {
|
|||
uri: 'mongodb://localhost:27017',
|
||||
database: '',
|
||||
}),
|
||||
...(this.options.mongoReadOnly
|
||||
? {
|
||||
uri: config.mongodb?.readUri ?? config.mongodb?.uri ?? 'mongodb://localhost:27017',
|
||||
database:
|
||||
extractMongoDatabaseFromUri(config.mongodb?.readUri) ??
|
||||
config.mongodb?.database ??
|
||||
'',
|
||||
readOnly: true,
|
||||
}
|
||||
: {}),
|
||||
enabled: this.options.enableMongoDB !== false && (config.mongodb?.enabled ?? true),
|
||||
},
|
||||
postgres: {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export type ServiceCradle = ServiceDefinitions;
|
|||
export interface ServiceContainerOptions {
|
||||
enableQuestDB?: boolean;
|
||||
enableMongoDB?: boolean;
|
||||
mongoReadOnly?: boolean;
|
||||
enablePostgres?: boolean;
|
||||
enableCache?: boolean;
|
||||
enableQueue?: boolean;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export function registerDatabaseServices(
|
|||
password: config.mongodb.password,
|
||||
authSource: config.mongodb.authSource,
|
||||
uri: config.mongodb.uri,
|
||||
readOnly: config.mongodb.readOnly ?? false,
|
||||
poolSettings: {
|
||||
maxPoolSize: config.mongodb.poolSize,
|
||||
minPoolSize: 1,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export interface QueuePoolConfig extends ConnectionPoolConfig {
|
|||
|
||||
export interface ConnectionFactoryConfig {
|
||||
service: string;
|
||||
environment: 'development' | 'production' | 'test';
|
||||
environment: 'development' | 'qa' | 'production' | 'test';
|
||||
pools?: {
|
||||
mongodb?: Partial<MongoDBPoolConfig>;
|
||||
postgres?: Partial<PostgreSQLPoolConfig>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue