项目作者: ktonon

项目描述 :
elm-serverless demo for latest release
高级语言: Elm
项目地址: git://github.com/ktonon/elm-serverless-demo.git
创建时间: 2017-01-11T01:33:48Z
项目社区:https://github.com/ktonon/elm-serverless-demo

开源协议:MIT License

下载


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:

  1. endpoints:
  2. ANY - https://***.execute-api.us-east-1.amazonaws.com/dev/
  3. 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: