fsharp(todolist-api): refactor: added a few random type definitions
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
38e6717f76
commit
67ae890717
|
@ -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]
|
||||||
|
|
Loading…
Reference in a new issue