Code Monkey home page Code Monkey logo

elm-serverless-demo's Introduction

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:

elm-serverless-demo's People

Contributors

ktonon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.