Skip to content

bradparker/servant-beam-realworld-example-app

Repository files navigation

RealWorld Example App

Build Status

A Servant and Beam 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 Servant and Beam including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Haskell community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

Status

With the caveat that the Authorization header format is slightly different, this is done:

┌─────────────────────────┬──────────┬──────────┐
│                         │ executed │   failed │
├─────────────────────────┼──────────┼──────────┤
│              iterations │        1 │        0 │
├─────────────────────────┼──────────┼──────────┤
│                requests │       31 │        0 │
├─────────────────────────┼──────────┼──────────┤
│            test-scripts │       46 │        0 │
├─────────────────────────┼──────────┼──────────┤
│      prerequest-scripts │       17 │        0 │
├─────────────────────────┼──────────┼──────────┤
│              assertions │      280 │        0 │
├─────────────────────────┴──────────┴──────────┤
│ total run duration: 18s                       │
├───────────────────────────────────────────────┤
│ total data received: 5.77KB (approx)          │
├───────────────────────────────────────────────┤
│ average response time: 25ms                   │
└───────────────────────────────────────────────┘

TODO

  • I'm not thrilled by that average response time, this is over localhost ... working with quite empty tables.

Getting started

  1. Use Nix to get all the Haskell package and application dependencies you need.
$ nix-shell
  1. Create .envrc from example and allow contents
$ cp .envrc.example .envrc
$ direnv allow
  1. Setup the database.
$ database/scripts/setup
  1. Run the test suite.
$ cabal new-test

You can run these in a watch mode using ghcid:

$ dev/watch-tests

Which might look something like this:

asciicast

  1. Run the app.
$ cabal new-run exe:realworld-conduit