From 1449e1ffdd02322381691d3fbc43482b3c2407af Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Sat, 3 Jul 2021 01:26:56 -0500 Subject: [PATCH] api: Updates for Nim 1.4.x. --- api/src/main/nim/personal_measure_api.nim | 4 ++-- api/src/main/nim/personal_measure_apipkg/api.nim | 2 +- api/src/main/nim/personal_measure_apipkg/db.nim | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/main/nim/personal_measure_api.nim b/api/src/main/nim/personal_measure_api.nim index a45864e..df6e113 100644 --- a/api/src/main/nim/personal_measure_api.nim +++ b/api/src/main/nim/personal_measure_api.nim @@ -27,7 +27,7 @@ proc loadConfig*(args: Table[string, docopt.Value] = initTable[string, docopt.Va try: json = parseFile(filePath) except: json = %DEFAULT_CONFIG - if not existsFile(filePath): + if not fileExists(filePath): info "created new configuration file \"" & filePath & "\"" filePath.writeFile($json) else: @@ -114,6 +114,6 @@ Options: if args["serve"]: start(ctx) except: - fatal "pit: " & getCurrentExceptionMsg() + fatal "personal_measure_api: " & getCurrentExceptionMsg() #raise getCurrentException() quit(QuitFailure) diff --git a/api/src/main/nim/personal_measure_apipkg/api.nim b/api/src/main/nim/personal_measure_apipkg/api.nim index c103787..2696b45 100644 --- a/api/src/main/nim/personal_measure_apipkg/api.nim +++ b/api/src/main/nim/personal_measure_apipkg/api.nim @@ -97,7 +97,7 @@ proc fromJWT*(ctx: PMApiContext, strTok: string): Session = ## Validate a given JWT and extract the session data. let jwt = toJWT(strTok) var secret = ctx.cfg.authSecret - if not jwt.verify(secret): raiseEx "Unable to verify auth token." + if not jwt.verify(secret, HS256): raiseEx "Unable to verify auth token." jwt.verifyTimeClaims() # Find the user record (if authenticated) diff --git a/api/src/main/nim/personal_measure_apipkg/db.nim b/api/src/main/nim/personal_measure_apipkg/db.nim index ce872f5..a11f55e 100644 --- a/api/src/main/nim/personal_measure_apipkg/db.nim +++ b/api/src/main/nim/personal_measure_apipkg/db.nim @@ -1,4 +1,4 @@ -import db_postgres, fiber_orm, uuids +import db_postgres, fiber_orm, sequtils, uuids import ./models @@ -8,7 +8,7 @@ type PMApiDb* = ref object conn: DbConn - + proc connect*(connString: string): PMApiDb = result = PMApiDb(conn: open("", "", "", connString))