WIP Refactor API into multiple sub-modules.

This commit is contained in:
Jonathan Bernard
2019-02-18 17:53:08 -06:00
parent 7bba4a0ad7
commit 1337d17105
8 changed files with 305 additions and 189 deletions

View File

@ -0,0 +1,27 @@
import json
import ./db
type
PMApiConfig* = object
authSecret*: string
dbConnString*: string
debug*: bool
port*: int
pwdCost*: int
PMApiContext* = object
cfg*: PMApiConfig
db*: PMApiDb
proc `%`*(cfg: PMApiConfig): JsonNode =
result = %* {
"authSecret": cfg.authSecret,
"dbConnString": cfg.dbConnString,
"debug": cfg.debug,
"port": cfg.port,
"pwdCost": cfg.pwdCost }
proc raiseEx*(reason: string): void =
raise newException(Exception, reason)