A Haskell Webserver Template
0

Configure Feed

Select the types of activity you want to include in your feed.

Haskell 82.4%
Just 6.5%
HTML 5.4%
PLpgSQL 3.3%
Nix 1.9%
Dockerfile 0.1%
Shell 0.1%
CSS 0.1%
JavaScript 0.1%
Other 0.3%
10 1 0

Clone this repository

https://tangled.org/dneaves.com/haskell-webserver-template https://tangled.org/did:plc:xpyuxe6mpc3zqkrfpl6hksnl
git@knot.dneaves.com:dneaves.com/haskell-webserver-template git@knot.dneaves.com:did:plc:xpyuxe6mpc3zqkrfpl6hksnl

For self-hosted knots, clone URLs may differ based on your setup.



README.md

A template webserver for Haskell.#

Tooling#

  • Uses nix to manage nix developer environment, building, etc.
  • Uses podman to manage containerization.
  • Uses dotenvx to manage secure environment keys.
  • Uses sqitch to manage database upgrades.
  • Uses just for managing bash/amber commands.

It also uses BulmaCSS. Explore a bit. Have fun with it.

Directory Structure#

application/ <- The Haskell part
├ Webserver/
| ├ Control/ <- Typeclasses, "services", and non-datatype structure stuff
| ├ Data/ <- Datatypes and misc related
| ├ Lib/ <- "Library adaptors" and other misc stuff I guess
| ├ Routes/ <- Route organization, split off from Routes.hs and go here
| ├ Middlewares.hs <- Middleware handlers
| ├ Routes.hs <- Routes starting point
├ justfile <- just file
├ Main.hs <- Well, Main
└ Prelude.hs <- Overridden Prelude. Observe, augment, replace, whatever

database/ <- The sqitch/Postgres part
├ deploy/ <- Upgrading SQL
├ revert/ <- Downgrading SQL
├ verify/ <- Testing that revisions were successful
├ docker-compose.yml <- For running Postgres locally
├ Dockerfile <- For running Postgres locally
├ justfile <- just file
└ sqitch.plan <- sqitch file

documentation/ <- Empty, but intended for use for documenting things

nix/ <- Nix stuff

static/ <- Statically served assets. HTML, CSS, Javascript, images, etc.

The rest is configuration files and stuff you can figure out, hopefully.

Getting Started#

  • Get familiar with the tools I've outlined.
  • Optional: Change all references to "Webserver" and "webserver" to whatever your application's name will be before running anything the first time. Can be done later, you'll just need to change the database stuff.
  • You don't need nix, but everything that's used here is already in there. So if you decide not to use devenv, make sure you install/handle all the parts you need yourself.
  • You'll need to get dotenvx situated. It needs to make a .env.keys file for you, and also put the public key value in .env.development.
    • When you get more situated, also make a .env.production, so you can differentiate values and stuff
    • If development/production file differentiation doesn't matter to you, make just a .env file and just use that. Be sure to change references to .env.development
  • just db start or just db run will get initial Postgres stuff set up for you locally if you used that. Otherwise, you'll need to set that up yourself
  • After (and while) Postgres is running, you need to run just db migrate to invoke sqitch to apply the two current migrations
  • While Postgres is running, run the app with just app run.