Skip to content

Commit ac8603b

Browse files
committed
Update port configuration to retrieve value from env.json
1 parent 5058883 commit ac8603b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/utils/config.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,25 @@ interface EnvConfig {
77
port: number;
88
}
99

10+
/**
11+
* Get port from env.json
12+
* @returns number
13+
*/
14+
export const getPort = (): number => {
15+
const __filename = fileURLToPath(import.meta.url);
16+
const __dirname = path.dirname(__filename);
17+
const envPath = path.resolve(__dirname, '../../env.json');
18+
const envData = JSON.parse(fs.readFileSync(envPath, 'utf-8')) as EnvConfig;
19+
return envData.port;
20+
}
21+
22+
/**
23+
* Configured settings
24+
*/
1025
export const configured = {
1126
directories: getDirectories(),
12-
port: 3000,
13-
}
27+
port: getPort(),
28+
};
1429

1530
/**
1631
* Get destination directories from env.json

0 commit comments

Comments
 (0)