blob: f4f811288d694cd7cad438a6b8f339057cf23090 (
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 :: PublicModule
public a = do
onGet "/api/songs" do
DB.run a.db (DB.hvals "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.run a.db (DB.hget "songnotes" hash) >>= \case
Nothing -> do
status status404
respondText "song not found"
Just val -> respondText $ decodeUtf8 val
|