blob: 397bc38ffe664cc2390e2c212f9a3202ae9afade (
plain)
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
|
module Config exposing (ApiResource(..), makeApiUrl)
import Utils exposing (templ)
baseUrl : String
baseUrl =
"http://localhost:3000"
type ApiResource
= ApiPosts
| ApiLikePost String
| ApiCompose
makeApiUrl : ApiResource -> String
makeApiUrl res =
String.replace "{baseUrl}" baseUrl <|
case res of
ApiPosts ->
"{baseUrl}/posts?_sort=createdAt&_order=desc"
ApiLikePost postId ->
"{baseUrl}/posts/{0}"
|> templ [ postId ]
ApiCompose ->
"{baseUrl}/posts"
|