MCPcopy Index your code
hub / github.com/api3dao/airnode / validateConfiguration

Function validateConfiguration

packages/airnode-validator/src/cli/cli.ts:21–41  ·  view source on GitHub ↗
(configPath: string, secretsPath: string)

Source from the content-addressed store, hash-verified

19];
20
21export const validateConfiguration = (configPath: string, secretsPath: string) => {
22 const goRawConfig = goSync(() => readFileSync(path.resolve(configPath), 'utf-8'));
23 if (!goRawConfig.success)
24 return fail(`Unable to read config file at "${configPath}". Reason: ${goRawConfig.error.message}`);
25
26 const goConfig = goSync(() => JSON.parse(goRawConfig.data));
27 if (!goConfig.success) return fail(`The configuration is not a valid JSON.`);
28
29 const goRawSecrets = goSync(() => readFileSync(path.resolve(secretsPath), 'utf-8'));
30 if (!goRawSecrets.success) {
31 return fail(`Unable to read secrets file at "${secretsPath}". Reason: ${goRawSecrets.error.message}`);
32 }
33
34 const goSecrets = goSync(() => dotenv.parse(goRawSecrets.data));
35 if (!goSecrets.success) return fail(`The secrets have incorrect format.`);
36
37 const parseResult = parseConfigWithSecrets(goConfig.data, goSecrets.data);
38 if (!parseResult.success) return fail(`The configuration is not valid. Reason: ${parseResult.error.message}`);
39
40 return succeed('The configuration is valid');
41};
42
43export const cli = () => {
44 const cliArguments = yargs(hideBin(process.argv))

Callers 1

cliFunction · 0.85

Calls 3

parseConfigWithSecretsFunction · 0.90
failFunction · 0.70
succeedFunction · 0.70

Tested by

no test coverage detected