blob: ecd263bcdf96a8bf4087aa68f4c8b33f8f1b48d5 (
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
|
module Config exposing (ApiResource(..), makeApiUrl)
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/{postId}"
|> String.replace "{postId}" postId
ApiCompose ->
"{baseUrl}/posts"
|