21 lines
529 B
TypeScript
21 lines
529 B
TypeScript
export type MongoConnectionConfig = {
|
|
username: string;
|
|
password: string;
|
|
host: string;
|
|
port: number;
|
|
database: string;
|
|
authSource?: string;
|
|
};
|
|
|
|
export function createMongoConnectionUri(
|
|
config: MongoConnectionConfig,
|
|
): string {
|
|
const authSource = config.authSource ?? "admin";
|
|
return `mongodb://${config.username}:${config.password}@${config.host}:${config.port}/${config.database}?authSource=${authSource}`;
|
|
}
|
|
|
|
export const mongoModuleConfig = {
|
|
connectionName: "primary",
|
|
defaultAuthSource: "admin",
|
|
};
|