-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83b6a62
commit f23878c
Showing
5 changed files
with
78 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
port module MyModule exposing (main) | ||
|
||
import CloudFront exposing (Model, Msg, cloudFront) | ||
import CloudFront.Header exposing (withHeader) | ||
import CloudFront.Lambda exposing (originResponse, toResponse) | ||
import Json.Decode as Decode | ||
import Json.Encode as Encode | ||
|
||
|
||
port inputEvent : (Decode.Value -> msg) -> Sub msg | ||
|
||
|
||
port outputEvent : Encode.Value -> Cmd msg | ||
|
||
|
||
main : Program () (Model ()) Msg | ||
main = | ||
( inputEvent, outputEvent ) | ||
|> (originResponse | ||
(\{ response, request } _ -> | ||
response | ||
|> withHeader { key = "cache-control", value = "public, max-age=31536000" } | ||
|> toResponse | ||
) | ||
|> cloudFront | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
let | ||
cloudfront = pkgs.callPackage (pkgs.stdenv.mkDerivation { | ||
name = "elm-aws-cloudfront"; | ||
src = fetchGit { | ||
url = "https://github.com/MarcoDaniels/elm-aws-cloudfront.git"; | ||
ref = "refs/tags/nix-1.0.0"; | ||
}; | ||
installPhase = '' | ||
mkdir -p $out | ||
cp $src/default.nix $out | ||
''; | ||
}) { }; | ||
|
||
in cloudfront.buildElmAWSCloudFront { | ||
src = ../../.; | ||
elmSrc = ../../nix/elm-srcs.nix; | ||
elmRegistryDat = ../../nix/registry.dat; | ||
lambdas = [ | ||
{ module = ./src/WebsiteRequest.elm; } | ||
{ module = ./src/WebsiteResponse.elm; } | ||
{ | ||
module = ./src/AssetRequest.elm; | ||
flags = [ ''token:"token"'' ''domain:"domain"'' ]; | ||
} | ||
{ module = ./src/AssetResponse.elm; } | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const {Elm} = require('./elm'); | ||
const app = Elm.MyModule.init(); | ||
exports.handler = (event, context, callback) => { | ||
const caller = (output) => { | ||
callback(null, output); | ||
app.ports.outputEvent.unsubscribe(caller); | ||
} | ||
app.ports.outputEvent.subscribe(caller); | ||
app.ports.inputEvent.send(event); | ||
} |