import json import ./db type PMApiConfig* = object authSecret*: string dbConnString*: string debug*: bool port*: int pwdCost*: int8 knownOrigins*: seq[string] PMApiContext* = object cfg*: PMApiConfig db*: PMApiDb BadRequestError* = object of CatchableError AuthError* = object of CatchableError proc `%`*(cfg: PMApiConfig): JsonNode = result = %* { "authSecret": cfg.authSecret, "dbConnString": cfg.dbConnString, "debug": cfg.debug, "port": cfg.port, "pwdCost": cfg.pwdCost, "knownOrigins": cfg.knownOrigins } template raiseEx*(errorType: type, reason: string): void = raise newException(errorType, reason) proc raiseEx*(reason: string): void = raise newException(Exception, reason)