summaryrefslogtreecommitdiff
path: root/fig-web/src/Fig/Web/Module/Bells.hs
blob: 7451079a214d302a3261135b582ebb9de2026078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Fig.Web.Module.Bells
  ( public
  ) where

import Fig.Prelude

import Fig.Utils.SExpr
import Fig.Web.Utils
import Fig.Web.Types
import qualified Fig.Web.DB as DB

public :: Module
public a = do
  onGet "/api/songs" do
    DB.hvals a.db "songnames" >>= \case
      Nothing -> do
        status status404
        respondText "no sounds found :("
      Just songs -> respondText . pretty . SExprList @Void $ SExprString . decodeUtf8 <$> songs
  onGet "/api/song/:hash" do
    hash <- pathParam "hash"
    DB.hget a.db "songnotes" hash >>= \case
      Nothing -> do
        status status404
        respondText "song not found"
      Just val -> respondText $ decodeUtf8 val