Skip to content

ktonon/elm-serverless-demo

Repository files navigation

elm serverless demo

This repo demonstrates how to use elm-package. It is kept up to date with that release version of the package. For a demo which is kept in sync with the master branch of elm-serverless see the demo embedded in that repo

Run locally

We use serverless-offline to run the server locally during development. To get started, clone this repo and then:

  • npm install
  • npm start

Which will start a server listening on port 3000. Note that the demo includes multiple, independent, elm-serverless programs which are deployed as a bundle. Each program contains:

  • API.elm - the main entry point of the Elm HTTP API
  • api.js - a small bridge from JavaScript to Elm

Learn by reading the demos in the following order:

Demo Path Description
Hello / Bare bones hello world app.
Routing /routing Parse request path into Elm data.
Forms /forms Shows how to parse a JSON body.
Config /config Load per-instance configuration.
Pipelines /pipelines Build chains of middleware.
SideEffects /side-effects Handle effects in the update loop.
Interop /interop Call JavaScript functions.
Quoted /quoted Shows one way to organize a project.

See serverless.yml and webpack.config.js for details on how elm-serverless apps get mapped to base paths.

Deploy to AWS Lambda

Setup AWS_REGION, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY in your environment. Make sure you have sufficient permissions to perform a serverless deployment (either admin rights, or something more restricted). Then npm run deploy:demo. If all goes well you'll see something like this in the output:

endpoints:
  ANY - https://***.execute-api.us-east-1.amazonaws.com/dev/
  ANY - https://***.execute-api.us-east-1.amazonaws.com/dev/{proxy+}

Call the first endpoint to test your deployed function.

How it works

Two tools are involved in getting your elm app on AWS Lambda:

About

elm-serverless demo for latest release

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published