-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMain.purs
More file actions
35 lines (29 loc) · 883 Bytes
/
Main.purs
File metadata and controls
35 lines (29 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Payload.Examples.Hello.Main where
import Prelude
import Effect (Effect)
import Effect.Aff (Aff)
import Payload.Server as Payload
import Payload.Spec (Spec(Spec), GET)
type Message =
{ id :: Int
, text :: String }
spec :: Spec {
getMessages :: GET "/users/<id>/messages?limit=<limit>" {
params :: { id :: Int },
query :: { limit :: Int },
response :: Array Message
}
}
spec = Spec
getMessages :: { params :: { id :: Int }, query :: { limit :: Int } } -> Aff (Array Message)
getMessages {params: {id}, query: {limit}} = pure
[{ id: 1, text: "Hey " <> show id}, { id: 2, text: "Limit " <> show limit }]
handlers ::
{ getMessages ::
{ params :: { id :: Int }
, query :: { limit :: Int }
} -> Aff (Array { id :: Int, text :: String })
}
handlers = { getMessages }
main :: Effect Unit
main = Payload.launch spec handlers