Skip to content

Commit

Permalink
fix(dal): Set authMechanism as per our environment config (#7285)
Browse files Browse the repository at this point in the history
  • Loading branch information
merrcury authored Dec 13, 2024
1 parent c25de5c commit 224a74d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/dal/src/dal.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import mongoose, { Connection, ConnectOptions } from 'mongoose';
import { AuthMechanism } from './types';

export const baseConfig: ConnectOptions = {
// AUTO_CREATE_INDEXES is deprecated, use MONGO_AUTO_CREATE_INDEXES
autoIndex: process.env.AUTO_CREATE_INDEXES === 'true' || process.env.MONGO_AUTO_CREATE_INDEXES === 'true',
maxIdleTimeMS: process.env.MONGO_MAX_IDLE_TIME_IN_MS ? Number(process.env.MONGO_MAX_IDLE_TIME_IN_MS) : 1000 * 30,
maxPoolSize: process.env.MONGO_MAX_POOL_SIZE ? Number(process.env.MONGO_MAX_POOL_SIZE) : 50,
minPoolSize: process.env.MONGO_MIN_POOL_SIZE ? Number(process.env.MONGO_MIN_POOL_SIZE) : 10,
authMechanism: (process.env.MONGO_AUTH_MECHANISM as AuthMechanism) || ('DEFAULT' as AuthMechanism),
};

export class DalService {
Expand Down
8 changes: 8 additions & 0 deletions libs/dal/src/types/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type AuthMechanism =
| 'DEFAULT'
| 'MONGODB-CR'
| 'SCRAM-SHA-1'
| 'SCRAM-SHA-256'
| 'MONGODB-X509'
| 'GSSAPI'
| 'PLAIN';
1 change: 1 addition & 0 deletions libs/dal/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './enforce';
export * from './helpers';
export * from './results';
export * from './error.enum';
export * from './auth';

0 comments on commit 224a74d

Please sign in to comment.