1
Fork 0

fsharp(todolist-api): refactor: added a few random type definitions

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2020-01-02 15:42:24 +02:00 committed by prescientmoon
parent 38e6717f76
commit 67ae890717
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -25,7 +25,7 @@ module App =
open Utils open Utils
open Db open Db
let todoById (id) = let todoById (id): WebPart =
let todo = let todo =
Context.getContext() Context.getContext()
|> Queries.getTodosById id |> Queries.getTodosById id
@ -35,7 +35,7 @@ module App =
| Some inner -> inner |> jsonToString |> OK | Some inner -> inner |> jsonToString |> OK
| None -> id |> sprintf "Cannot find todo with id %i" |> NOT_FOUND | None -> id |> sprintf "Cannot find todo with id %i" |> NOT_FOUND
let updateTodo (id) = let updateTodo (id): WebPart =
let dbContext = Context.getContext() let dbContext = Context.getContext()
let todo = dbContext |> Queries.getTodosById id let todo = dbContext |> Queries.getTodosById id
@ -59,6 +59,7 @@ module App =
| None -> id |> sprintf "Cannot find todo with id %i" |> NOT_FOUND | None -> id |> sprintf "Cannot find todo with id %i" |> NOT_FOUND
let mainWebPart: WebPart = choose [ let mainWebPart: WebPart = choose [
GET >=> pathScan "/todos/%i" todoById GET >=> pathScan "/todos/%i" todoById
PUT >=> pathScan "/todos/%i" updateTodo] PUT >=> pathScan "/todos/%i" updateTodo]