32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import yaml from 'js-yaml';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import {Registry} from '@cerc-io/laconic-sdk';
|
|
|
|
const loadConfigFile = (configFilePath: string): any => {
|
|
const resolvedFilePath = path.resolve(process.cwd(), configFilePath);
|
|
const configFile = fs.readFileSync(resolvedFilePath, 'utf-8');
|
|
return yaml.load(configFile);
|
|
};
|
|
|
|
export const Config = {
|
|
LISTEN_PORT: parseInt(process.env.LISTEN_PORT || '9555'),
|
|
LISTEN_ADDR: process.env.LISTEN_ADDR || '0.0.0.0',
|
|
LACONIC_CONFIG: process.env.LACONIC_CONFIG || '/etc/config/laconic.yml',
|
|
DEPLOYER_STATE:
|
|
process.env.DEPLOYER_STATE || '/srv/deployments/autodeploy.state',
|
|
UNDEPLOYER_STATE:
|
|
process.env.UNDEPLOYER_STATE || '/srv/deployments/autoundeploy.state',
|
|
BUILD_LOGS: process.env.BUILD_LOGS || '/srv/logs',
|
|
};
|
|
|
|
export const getRegistry = (): Registry => {
|
|
const laconicConfig = loadConfigFile(Config.LACONIC_CONFIG);
|
|
//TODO(telackey): Use a pool.
|
|
return new Registry(
|
|
laconicConfig.services?.cns?.gqlEndpoint,
|
|
laconicConfig.services?.cns?.restEndpoint,
|
|
laconicConfig.services?.cns?.chainId,
|
|
);
|
|
};
|