Elm codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
This codebase was created to demonstrate a fully fledged fullstack application built with Elm including CRUD operations, authentication, routing, pagination, and more.
For more information on how this works with other frontends/backends, head over to the RealWorld repo.
We have a few frontend Elm implementations of the RealWorld App Spec, let's make a backend one!
See a full stack Elm version here! (It's rtfeldman/elm-spa-example connected up to this api as the backend).
- The api is an Elm worker running on NodeJS, and uses elm-concurrent-task to interop with a few JS libraries and a Postgres database.
- All of the business logic can be found in Routes.elm and in Domain modules.
- Each endpoint handler is a
ConcurrentTask
which handles a thin layer of interop with some JS libraries (bcryptjs
,jsonwebtoken
andnode-pg
). - All of the code in Lib is pretty generic and could more or less be extracted out into separate packages as is (For JWT, Bcrypt, Postgres and an Http Server).
- The api is deployed as a single vercel serverless function.
- Storage is backed by vercel postgres.
Make sure you have NodeJS
and Postgres
installed.
Install dependencies with:
npm install
Create a postgres database with:
CREATE DATABASE realworld_api
Run the schema migration with:
psql -d realworld_api -a -f ./db/migrations/v1_initial_schema.up.sql
Add the following environment variables:
export POSTGRES_URL=postgresql://localhost/realworld_api
export JWT_SECRET=sUpErSecReTjWtSecreT123456
export PORT=3000
Run the api in dev mode with:
npm start
This starts the api with a single express endpoint.
Import the Postman Collection to try out interacting with the api.