config.ts 989 Bytes
Newer Older
Maxym Borodenko's avatar
Maxym Borodenko committed
1
2
3
4
5
import * as minimist from 'minimist';

// console.log(process.argv);
const argv = minimist(process.argv.slice(2), {
    string: [
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
6
        '--api-url', '--client-id', '--client-secret', '--frontend-path', '--google-client-id',
Maxym Borodenko's avatar
Maxym Borodenko committed
7
8
9
10
11
12
13
14
15
    ],
});
console.dir(argv);

/**
 * Application configuration
 */
const config = {
    // Timeout (ms) for proxied calls to the API
16
17
    frontendPath: argv['frontend-path'] || '',
    // Backend
18
    apiTimeout: +(argv['api-timeout'] || 10000),
19
    apiUrl: argv['api-url'] || 'http://localhost:8080',
20
21
    clientId: argv['client-id'] || 'defaultclient@localhost',
    clientSecret: argv['client-secret'] || 'changeme',
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
22
    googleClientId: argv['google-client-id'] || '',
Maxym Borodenko's avatar
Maxym Borodenko committed
23
24
};

25
26
27
28
29
if (config.frontendPath.endsWith('/')) {
  console.log(`FRONTEND_PATH "${config.frontendPath}" must not end with trailing /`);
  config.frontendPath = config.frontendPath.substring(0, config.frontendPath.lastIndexOf('/'));
}

Maxym Borodenko's avatar
Maxym Borodenko committed
30
31
32
console.log('Catalog config', config);

export default config;