Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eeue56/take-home
A take-home application server written in Elm and only Elm
https://github.com/eeue56/take-home
Last synced: 5 days ago
JSON representation
A take-home application server written in Elm and only Elm
- Host: GitHub
- URL: https://github.com/eeue56/take-home
- Owner: eeue56
- License: bsd-3-clause
- Created: 2015-11-13T22:56:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-03T11:49:43.000Z (over 8 years ago)
- Last Synced: 2024-08-01T12:22:09.552Z (3 months ago)
- Language: Elm
- Homepage:
- Size: 361 KB
- Stars: 357
- Watchers: 34
- Forks: 16
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - eeue56/take-home - A take-home application server written in Elm and only Elm (others)
README
# take-home
take-home is the world's first open-source project with all parts of the stack written in only Elm. The server-side code is Elm. The stylesheets are Elm. The client-side code is Elm.There's even a branch which shows how the build tools could be in Elm. We went all out to write as much as we could in Elm!
# Installation
## Requirements
- Node: `4.1.2`
- Elm: `0.16`## How to run
- Clone the repo
- `npm install`
- `./run_prod.sh`# Interesting parts
There's a lot in this project to take in. These are the important parts to look at!
## Support summary
In a brief summary, this program has support for the following in Elm
- Server-side programs
- [A web server](https://github.com/NoRedInk/take-home/blob/master/instance/server/Main.elm)
- [Database support in Elm](https://github.com/NoRedInk/take-home/blob/master/instance/server/User.elm)
- [Build tools](https://github.com/NoRedInk/take-home/pull/2)
- Env/JSON config support
- [Type-safe CSS](https://github.com/NoRedInk/take-home/blob/master/instance/server/Client/Admin/Styles.elm)
- [Server-side rendered client-side HTML](https://github.com/NoRedInk/take-home/blob/master/instance/server/Router.elm#L118)
- [Shared models between client and server side code](https://github.com/NoRedInk/take-home/tree/master/instance/server/Shared)
- [Server-side templating for data injection](https://github.com/NoRedInk/take-home/blob/master/instance/server/Client/StartTakeHome/App.elm#L22)### Some extras
- Moment.js wrapper both client and server side
- Knox server side
- Uuid server side
- Nedb server side
- StartApp on the server## Framework
While this project provides a good start place for anyone wishing to use full-stack Elm, it does not provide a "do everything" framework like Rails or Django just yet. There is work to make it more like a framework with scripting, but at this time it's not there yet.
# How does it work?
The server itself follows the Elm architecture. It uses a [modified startapp](https://github.com/NoRedInk/start-app) implementation. This means you have the following core functions
```elm
update : Action -> Model -> (Model, Effects Action)
routeIncoming : Connection -> Model -> (Model, Effects Action)
```Notice how there's no longer a view. The update function is responsible for updating the model, while the router is responsible for writing replies to the client.
# Future work
## Create a sensible way of having global footers and headers
At the moment, it's hard to link things in like stylesheets in each view without having a monolithic view function that rendered conditionally. It would be much more ideal to support a way of linking CSS in a header that was somehow included everywhere
## Session data
There's no way of storing session data right now.
# FAQ
## Should I use this in production?
*No!* This project was an experiment and a proof of concept. A lot of the ideas in this project are really cool. But being cool doesn't make for a production-ready system. Let's talk about a day in the life of a server-side Elm programmer.
- Write some business logic in Elm
- Realise that you need some library support that doesn't exist in Elm
- Spend the rest of the day fighting NodeAs an Elm programmer, I like to write Elm! As a server-side Elm programmer, I hate writing yet another integration library that wraps around a Node library that uses mutable objects and callbacks in a weird way. There are a lot of battles that you have to face everyday writing libraries that work with Node. Sometimes there just isn't a way to make Node libraries play nicely with Elm. This does not make for a stable runtime, nor a stable platform.
The tl;dr here is that Node is not the ideal platform for server-side Elm. An alternate platform to base itself on would be great, but is unlikely to happen "soon". Please take away some of the ideas here and think about them! But if you value your sanity, your stability and your users, don't use this proof of concept for anything more than interest!
# Credit
Fresheyeball provided the [PoC](https://github.com/Fresheyeball/elm-http-server) HTTP server implementation that we rewrote parts of [here](https://github.com/eeue56/servelm) and then applied to production!
rtfeldman provided CSS support through [elm-css](https://github.com/rtfeldman/elm-css)
# Awesome!
If you think this is awesome, why not apply to come [join us](https://www.noredink.com/jobs) make things?
---
[![NoRedInk](https://cloud.githubusercontent.com/assets/1094080/9069346/99522418-3a9d-11e5-8175-1c2bfd7a2ffe.png)][team]
[team]: http://noredink.com/about/team