44 * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
55 */
66
7- import fs from 'node:fs' ;
8- import path from 'node:path' ;
9- import { fileURLToPath } from 'node:url' ;
7+ import { APPLICATION_INSIGHTS_CONNECTION_STRING } from '../config.js' ;
108
119/**
1210 * Utility modules for the B2C DX MCP server.
@@ -20,30 +18,10 @@ import {fileURLToPath} from 'node:url';
2018export * from './constants.js' ;
2119export * from './types.js' ;
2220
23- const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
24-
25- /**
26- * Load a value from the config.json file.
27- * @param key - The key to load from the config file
28- * @returns The value or undefined if not found
29- */
30- function loadConfigValue ( key : string ) : string | undefined {
31- try {
32- const cfgPath = path . resolve ( __dirname , './config.json' ) ;
33- if ( ! fs . existsSync ( cfgPath ) ) return undefined ;
34- const raw = fs . readFileSync ( cfgPath , 'utf8' ) ;
35- const cfg = JSON . parse ( raw ) as Record < string , unknown > ;
36- const v = cfg ?. [ key ] ;
37- return typeof v === 'string' && v . trim ( ) ? v . trim ( ) : undefined ;
38- } catch {
39- return undefined ;
40- }
41- }
42-
4321/**
44- * Load the Application Insights connection string from the config.json file .
22+ * Load the Application Insights connection string.
4523 * @returns The connection string or undefined if not configured
4624 */
4725export function loadAppInsightsKey ( ) : string | undefined {
48- return loadConfigValue ( 'applicationInsightsConnectionString' ) ;
26+ return APPLICATION_INSIGHTS_CONNECTION_STRING ;
4927}
0 commit comments