chore: identify api mongo connections

This commit is contained in:
dahyeon committed 2026-06-26 09:56:58 -07:00
1 parent 51ea9c42d3
commit 4ab5722759
2 files changed
+25 -2

No files matched your search

@@ -9,6 +9,13 @@ export function resolveMongoDbName(nodeEnv = process.env.NODE_ENV): string {
return 'lolympus-dev';
}
export function resolveMongoAppName(
nodeEnv = process.env.NODE_ENV,
pid = process.pid,
): string {
return `lolympus-api:${nodeEnv || 'dev'}:${pid}`;
}
@Injectable({ scope: Scope.DEFAULT })
export class ConnectionService implements OnModuleInit {
private connection: mongoose.Connection | null = null;
@@ -25,15 +32,19 @@ export class ConnectionService implements OnModuleInit {
'MONGODB_CONNECTION_STRING',
);
const dbName = resolveMongoDbName();
const appName = resolveMongoAppName();
const defaultConnection = await mongoose
.createConnection(connectionString, {
dbName,
appName,
minPoolSize: 10,
maxPoolSize: 20,
})
.asPromise();
this.connection = defaultConnection;
console.log(`Default Connection이 새로 생성됨. dbName=${dbName}`);
console.log(
`Default Connection이 새로 생성됨. dbName=${dbName} appName=${appName}`,
);
return this.connection;
}