Code Monkey home page Code Monkey logo

servelm's Introduction

Servelm - Elm Http Server

Deprecated. Server side elm is not designed to work this way.

This server, along with rtfeldman's Elm stylesheets, means that we can now have full stack Elm support. At no point in the development of an application will you have to write anything other than Elm!

It now supports server-side rendering of elm-html.

A demo can be found here. The styling is done through compile-time correct CSS provided by elm-stylesheets.

APIs exposed

The Http.Server module allows you to create servers and run them.

Sending out Elm

Use the Http.Response.writeElm function to compile an Elm file on request. It will compile an Elm file found with name + ".elm"". It will write the output to a file in the same folder as name + ".html". This will then be served out to the client. There is basic caching involved at the moment, which works based on the lifecycle of the server. Restart the server if you make any changes.

This is enabled by the node-elm-compiler package.

It also supports server-side rendering of elm-html, through using the vdom-to-html package.

Get started

To start Elm inside of Node simply this to the end of your compiled Elm code.

Elm.worker(Elm.Main);

Take a look at example/run.sh to see a complete usage

elm make example/server/Main.elm --output=example/main.js
echo "Elm.worker(Elm.Main);" >> example/main.js
node example/main.js

Run the example

This project depends on Node.js and the node command.

example/run.sh

Then load up the browser to see it working!

Credit

Originally inspired by https://github.com/Fresheyeball/elm-http-server.

There was some great work already there, I just cleaned it up a little and integrated it with some other packages.

servelm's People

Contributors

0xr avatar conorhastings avatar eeue56 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

servelm's Issues

More explanation about why this package became depreciated

I'm new to elm and exploring what people have done with elm. As with most frameworks / front-end languages a Todo example is to be expected. However a back-end library built in a language designed for the front-end seems interesting (node...)

Depreciated. Server side elm is not designed to work this way.

How should server side elm be designed? What things did this project get wrong?

Can you publish the package.json ?

it tries to load:

    var mime = require('mime');
    var compiler = require('node-elm-compiler');
    var toHtml = require('vdom-to-html');

but no npm dependencies are declared.

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.