diff options
author | Julien Dessaux | 2021-10-26 21:41:39 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-10-26 21:41:39 +0200 |
commit | 7f79a49bff7883db126481f8c8a795aa312e3505 (patch) | |
tree | f04efeff6440f580a9f109686e1cb30822c40ad6 /src/short.nim | |
parent | Added 6 months expiration option (diff) | |
download | short-7f79a49bff7883db126481f8c8a795aa312e3505.tar.gz short-7f79a49bff7883db126481f8c8a795aa312e3505.tar.bz2 short-7f79a49bff7883db126481f8c8a795aa312e3505.zip |
cosmetics
Diffstat (limited to 'src/short.nim')
-rw-r--r-- | src/short.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/short.nim b/src/short.nim index fa5486a..7057779 100644 --- a/src/short.nim +++ b/src/short.nim @@ -13,7 +13,7 @@ const favicon = staticRead("../static/favicon.ico") var db {.threadvar.}: DbConn -proc initDB() {.raises: [SqliteError].}= +proc initDB() {.raises: [SqliteError].} = if not db.isOpen(): db = openDatabase("data/short.db") if not db.Migrate(): @@ -36,7 +36,7 @@ func renderNoShort(req: ShortUrl): string {.raises: [].} = func renderError(code: int, msg: string): string {.raises: [].} = compileTemplateFile(getScriptDir() / "templates/error.html") -proc handleToken(token:string): (HttpCode, string) {.raises: [].} = +proc handleToken(token: string): (HttpCode, string) {.raises: [].} = try: let tokenRegexp = re"^[\w]{24}$" if not match(token, tokenRegexp): @@ -89,7 +89,7 @@ proc handleIndexPost(params: Table[string, string]): (HttpCode, string) {.raises return (Http400, renderError(400, "Bad Request")) input.Token = $genOid() input.Created = times.now() - input.Expires = input.Created + initDuration(minutes=exp) + input.Expires = input.Created + initDuration(minutes = exp) try: db.AddUrl(input) except SqliteError: |