From a0f96706883b87c8b9250de9266b6f2de3456bf3 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Mon, 5 Jul 2021 11:35:35 -0500 Subject: [PATCH] api: Use the standard config pattern for KNOWN_ORIGINS. --- api/src/main/nim/personal_measure_api.nim | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/api/src/main/nim/personal_measure_api.nim b/api/src/main/nim/personal_measure_api.nim index df6e113..3f03c8d 100644 --- a/api/src/main/nim/personal_measure_api.nim +++ b/api/src/main/nim/personal_measure_api.nim @@ -34,19 +34,15 @@ proc loadConfig*(args: Table[string, docopt.Value] = initTable[string, docopt.Va warn "Cannot read configuration file \"" & filePath & "\":\n\t" & getCurrentExceptionMsg() - let knownOriginsArray = - if json.hasKey("knownOrigins"): json["knownOrigins"] - else: newJArray() - let cfg = CombinedConfig(docopt: args, json: json) result = PMApiConfig( authSecret: cfg.getVal("auth-secret"), dbConnString: cfg.getVal("db-conn-string"), debug: "true".startsWith(cfg.getVal("debug", "false").toLower()), - port: parseInt(cfg.getVal("port", "8080")), + port: parseInt(cfg.getVal("port", "8100")), pwdCost: cast[int8](parseInt(cfg.getVal("pwd-cost", "11"))), - knownOrigins: toSeq(knownOriginsArray).mapIt(it.getStr)) + knownOrigins: cfg.getVal("known-origins")[1..^2].split(',').mapIt(it[1..^2])) proc initContext(args: Table[string, docopt.Value]): PMApiContext =