summaryrefslogtreecommitdiffstats
path: root/src/Config.elm
blob: c3df2b04ddb52ef34e6a79df007344e5c8273a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Config exposing (ApiResource(..), makeApiUrl)


baseUrl : String
baseUrl =
    "http://localhost:3000"


type ApiResource
    = ApiPosts
    | ApiLikePost String


makeApiUrl : ApiResource -> String
makeApiUrl res =
    String.replace "{baseUrl}" baseUrl <|
        case res of
            ApiPosts ->
                "{baseUrl}/posts"

            ApiLikePost postId ->
                "{baseUrl}/posts/{postId}"
                    |> String.replace "{postId}" postId