Fix bug in POST measures API.

This commit is contained in:
Jonathan Bernard 2019-03-16 23:57:07 -05:00
parent 9d8ad6bf74
commit 5887368ed1
4 changed files with 6 additions and 5 deletions

View File

@ -389,18 +389,22 @@ proc start*(ctx: PMApiContext): void =
let slug =
if jsonBody.hasKey("slug"): jsonBody["slug"].getStr.nameToSlug
else: jsonBody["slug"].getStr.nameToSlug
else: jsonBody["name"].getStr.nameToSlug
let name =
if jsonBody.hasKey("name"): jsonBody["name"].getStr
else: jsonBody["slug"].getStr.capitalize
let config =
if jsonBody.hasKey("config"): jsonBody["config"]
else: newJObject()
var newMeasure = Measure(
userId: session.user.id,
slug: slug,
name: name,
description: jsonBody.getIfExists("description").getStr(""),
config: jsonBody.getOrFail("config"))
config: config)
resp($(%ctx.db.createMeasure(newMeasure)), JSON)

View File

@ -1 +0,0 @@
Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6Imp3dCJ9.eyJleHAiOjE1NTIzMjYxODMsInN1YiI6IjA3NWJjYzhmLWE4N2QtNDRjZS04MDk5LWQ3ZGExZjYxYTc1YSIsImlhdCI6MTU1MjIzOTc4M30.RjE0MjYzMkFDOTc4RjZFNTYyMDVBMTY5MjExNkJGQ0QzNkQ1QjZFNzVCODBDMThENTc1M0Y0MjhDMkNFMjE3RA

View File

@ -1 +0,0 @@
auth-token-jdb.txt

View File

@ -1 +0,0 @@
../src/util/bash/client.sh