Ver código fonte

Update for deployment

Cadel Watson 4 meses atrás
pai
commit
8d0e5ab45a
3 arquivos alterados com 9 adições e 29 exclusões
  1. 2 0
      .gitignore
  2. 4 4
      server/main.py
  3. 3 25
      src/API.elm

+ 2 - 0
.gitignore

@@ -8,3 +8,5 @@ elm-stuff/
 /data/sets/
 /data/drafts/
 /server/__pycache__/
+drafter.service
+update_and_release.sh

+ 4 - 4
server/main.py

@@ -32,13 +32,13 @@ def discover_sets():
     return sets
 
 
-@app.get("/sets")
+@app.get("/api/sets")
 def read_sets():
     sets = discover_sets()
     return {"sets": sets}
 
 
-@app.get("/sets/{set_name}/cards")
+@app.get("/api/sets/{set_name}/cards")
 def read_item(set_name: str):
     if set_name not in discover_sets():
         return {"error": "Set not found"}
@@ -51,7 +51,7 @@ def read_item(set_name: str):
     return {"data": card_data}
 
 
-@app.get("/sets/{set_name}/ratings")
+@app.get("/api/sets/{set_name}/ratings")
 def read_item(set_name: str):
     if set_name not in discover_sets():
         return {"error": "Set not found"}
@@ -64,7 +64,7 @@ def read_item(set_name: str):
     return {"data": card_data}
 
 
-@app.get("/sets/{set_name}")
+@app.get("/api/sets/{set_name}")
 def read_item(set_name: str):
     if set_name not in discover_sets():
         return {"error": "Set not found"}

+ 3 - 25
src/API.elm

@@ -1,4 +1,4 @@
-module API exposing (getDraft, getDrafts, getSetData, getSets)
+module API exposing (getDraft, getSetData, getSets)
 
 import Database exposing (Database)
 import DraftMeta exposing (DraftMeta)
@@ -7,20 +7,10 @@ import Json.Decode as Decode
 import Url.Builder as UrlB
 
 
-apiUrl : String
-apiUrl =
-    "http://localhost:8000"
-
-
-makeApiUrl : List String -> String
-makeApiUrl paths =
-    apiUrl ++ "/" ++ String.join "/" paths
-
-
 getSets : (Result String (List String) -> msg) -> Cmd msg
 getSets onSuccess =
     Http.get
-        { url = makeApiUrl [ "sets" ]
+        { url = UrlB.absolute [ "api", "sets" ] []
         , expect =
             Http.expectJson (Result.mapError httpErrorToString >> onSuccess)
                 (Decode.field "sets"
@@ -34,7 +24,7 @@ getSetData setCode onSuccess =
     Http.request
         { method = "GET"
         , headers = []
-        , url = makeApiUrl [ "sets", setCode ]
+        , url = UrlB.absolute [ "api", "sets", setCode ] []
         , body = Http.emptyBody
         , expect = Http.expectJson (Result.mapError httpErrorToString >> onSuccess) Database.decoder
         , timeout = Nothing
@@ -42,18 +32,6 @@ getSetData setCode onSuccess =
         }
 
 
-getDrafts : String -> (Result String (List DraftMeta) -> msg) -> Cmd msg
-getDrafts historyUrl onSuccess =
-    Http.get
-        { url = apiUrl ++ UrlB.absolute [ "drafts" ] [ UrlB.string "history" historyUrl ]
-        , expect =
-            Http.expectJson (Result.mapError httpErrorToString >> onSuccess)
-                (Decode.field "drafts"
-                    (Decode.list DraftMeta.decoder)
-                )
-        }
-
-
 getDraft : String -> (Result String DraftMeta -> msg) -> Cmd msg
 getDraft draftID onSuccess =
     Http.get