From 1f2e453d0c9f8412b9032cb4e655713ecdcf1fa3 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Mon, 26 May 2025 04:43:38 -0400 Subject: web: Refactor major style --- fig-web/src/Fig/Web/Module/Bells.hs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 fig-web/src/Fig/Web/Module/Bells.hs (limited to 'fig-web/src/Fig/Web/Module/Bells.hs') diff --git a/fig-web/src/Fig/Web/Module/Bells.hs b/fig-web/src/Fig/Web/Module/Bells.hs new file mode 100644 index 0000000..7451079 --- /dev/null +++ b/fig-web/src/Fig/Web/Module/Bells.hs @@ -0,0 +1,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 -- cgit v1.2.3