Skip to content

Commit ad91bfc

Browse files
committed
Use object spread
1 parent cf7d011 commit ad91bfc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/config.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ interface UserConfig extends Record<string, string> {
1313
apiBaseUrl: string;
1414
clientId: string;
1515
stateFile: string;
16-
projectId: string;
1716
}
1817

1918
const defaults: UserConfig = {
2019
apiBaseUrl: "https://cloud.mongodb.com/",
2120
clientId: "0oabtxactgS3gHIR0297",
2221
stateFile: path.join(localDataPath, "state.json"),
23-
projectId: "",
2422
};
2523

26-
const mergedUserConfig = Object.assign({}, defaults, getFileConfig(), getEnvConfig(), getCliConfig());
24+
const mergedUserConfig = {
25+
...defaults,
26+
...getFileConfig(),
27+
...getEnvConfig(),
28+
...getCliConfig(),
29+
};
2730

2831
const __filename = fileURLToPath(import.meta.url);
2932
const __dirname = path.dirname(__filename);
@@ -68,12 +71,12 @@ function getEnvConfig(): Partial<UserConfig> {
6871
};
6972

7073
const result: Partial<UserConfig> = {};
71-
Object.keys(defaults).forEach((key) => {
74+
for (const key of Object.keys(defaults)) {
7275
const envVarName = `MDB_MCP_${camelCaseToSNAKE_UPPER_CASE(key)}`;
7376
if (process.env[envVarName]) {
74-
result[key as keyof UserConfig] = process.env[envVarName];
77+
result[key] = process.env[envVarName];
7578
}
76-
});
79+
}
7780

7881
return result;
7982
}

0 commit comments

Comments
 (0)