mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-24 06:54:03 +03:00
Wire through secrets more.
This commit is contained in:
parent
682e3f9c11
commit
dd42d5eb78
@ -96,7 +96,7 @@ successCodec =
|
||||
type Effect pathKey
|
||||
= NoEffect
|
||||
| SendJsData (ToJsPayload pathKey)
|
||||
| FetchHttp String
|
||||
| FetchHttp Secrets.UrlWithSecrets
|
||||
| Batch (List (Effect pathKey))
|
||||
|
||||
|
||||
@ -220,14 +220,19 @@ perform cliMsgConstructor toJsPort effect =
|
||||
|> List.map (perform cliMsgConstructor toJsPort)
|
||||
|> Cmd.batch
|
||||
|
||||
FetchHttp url ->
|
||||
FetchHttp urlWithSecrets ->
|
||||
let
|
||||
realSecrets =
|
||||
-- TODO @@@@@
|
||||
Secrets.empty
|
||||
in
|
||||
Http.get
|
||||
{ url = url
|
||||
{ url = urlWithSecrets realSecrets |> Result.withDefault "TODO" -- TODO handle error
|
||||
, expect =
|
||||
Http.expectString
|
||||
(\response ->
|
||||
GotStaticHttpResponse
|
||||
{ url = url
|
||||
{ url = Secrets.useFakeSecrets urlWithSecrets
|
||||
, response = response
|
||||
}
|
||||
|> cliMsgConstructor
|
||||
@ -387,20 +392,22 @@ performStaticHttpRequests staticRequests =
|
||||
|> List.map
|
||||
(\( pagePath, StaticHttpRequest.Request ( urls, lookup ) ) ->
|
||||
urls
|
||||
|> List.filterMap
|
||||
(\urlBuilder ->
|
||||
case urlBuilder secrets of
|
||||
Ok url ->
|
||||
Just url
|
||||
|
||||
Err _ ->
|
||||
-- @@@@@@@@@ TODO handle error here
|
||||
Nothing
|
||||
)
|
||||
-- |> List.map
|
||||
-- (\url ->
|
||||
-- url
|
||||
-- -- case urlBuilder secrets of
|
||||
-- -- Ok url ->
|
||||
-- -- Just url
|
||||
-- --
|
||||
-- -- Err _ ->
|
||||
-- -- -- @@@@@@@@@ TODO handle error here
|
||||
-- -- Nothing
|
||||
-- )
|
||||
)
|
||||
|> List.concat
|
||||
|> Set.fromList
|
||||
|> Set.toList
|
||||
-- TODO prevent duplicates... can't because Set needs comparable
|
||||
-- |> Set.fromList
|
||||
-- |> Set.toList
|
||||
|> List.map FetchHttp
|
||||
|> Batch
|
||||
|
||||
|
@ -3,6 +3,10 @@ module Secrets exposing (..)
|
||||
import Dict exposing (Dict)
|
||||
|
||||
|
||||
type alias UrlWithSecrets =
|
||||
Secrets -> Result String String
|
||||
|
||||
|
||||
type Secrets
|
||||
= Secrets (Dict String String)
|
||||
| Protected
|
||||
|
@ -12,6 +12,7 @@ import Pages.Internal.Platform.Cli as Main exposing (..)
|
||||
import Pages.Manifest as Manifest
|
||||
import Pages.PagePath as PagePath
|
||||
import ProgramTest exposing (ProgramTest)
|
||||
import Secrets
|
||||
import SimulatedEffect.Cmd
|
||||
import SimulatedEffect.Http
|
||||
import SimulatedEffect.Ports
|
||||
@ -206,14 +207,19 @@ simulateEffects effect =
|
||||
|> List.map simulateEffects
|
||||
|> SimulatedEffect.Cmd.batch
|
||||
|
||||
FetchHttp url ->
|
||||
FetchHttp urlWithSecrets ->
|
||||
let
|
||||
realSecrets =
|
||||
-- TODO @@@@@
|
||||
Secrets.empty
|
||||
in
|
||||
SimulatedEffect.Http.get
|
||||
{ url = url
|
||||
{ url = urlWithSecrets realSecrets |> Result.withDefault "TODO" -- TODO handle error
|
||||
, expect =
|
||||
SimulatedEffect.Http.expectString
|
||||
(\response ->
|
||||
Main.GotStaticHttpResponse
|
||||
{ url = url
|
||||
GotStaticHttpResponse
|
||||
{ url = Secrets.useFakeSecrets urlWithSecrets
|
||||
, response = response
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user