ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
import json, options, asyncdispatch
import nimhafas

const ds100Json = staticRead "../../ds100reverse.json"


proc suggestionsEndpoint* (data: JsonNode): Future[JsonNode] {.async.} =
  let ds100 = parseJson(ds100Json)
  if ds100.hasKey(data["query"].getStr):
    return %* (await suggestions(SuggestionsParams(query: ds100[data["query"].getStr].getStr)))
  else:
    return %* (await suggestions(data.to(SuggestionsParams)))