/todo-list-ihp

About TODO-list backend application implemented with Yesod web framework

Primary LanguageHaskell

TODO-list by IHP

Intro

Here you may find TODO-list full-stack application implemented generated with IHP, web framework for Haskell.

It has basic CRUD operations, renders HTML as a response, uses built-in Postgres server as a storage, and additionally implements a simple custom logger middleware.

The main goal of this project is to provide a basic example of implementing web app with IHP framework. In particular, to show how (mostly generated) code looks, and to demonstrate how custom middleware could be added. So to make life a bit easier for (future) Haskell web developers. It's already pretty easy with IHP, though ๐Ÿ˜‰

This code complements the talk "How to Choose a Haskell Web Framework" I presented at Haskell eXchange 2022.

In this talk, I show how some of Haskell web tools approach web development. In particular, there are 3 of them โ€” Servant, Yesod and IHP.

There are also corresponding Servant and Yesod TODO-list implementations.

Check out the presentation slides and the talk recording, and contact me if you have any questions ๐Ÿ™‚

API

As application is intended to have just basic CRUD operations, only generated API is used, and here it is

  • GET /Tasks โ€” get all tasks
  • POST /NewTask โ€” create new task
  • GET /ShowTask?taskId={id} โ€” get existing task by id
  • PUT /EditTask?taskId={id} โ€” update existing task by id
  • DELETE /DeleteTask?taskId={id} โ€” delete existing task by id

Web app demo

Here is how task creation, deletion and update may look like.

Custom logger middleware

Simple logger here just extracts requestโ€™s URL path and logs it with "Info" verbosity level.

For example,

[Info] url-path=Tasks
[Info] url-path=ShowTask
[Info] url-path=Tasks
[Info] url-path=NewTask
[Info] url-path=Tasks
[Info] url-path=DeleteTask

Prerequisites

Run

To run the app, simply start the development server

> ./start
IHP> Server started
...

Hope you'll find it helpful ๐Ÿ’™