summaryrefslogtreecommitdiff
path: root/fig-web/src/Fig/Web/Module/Bells.hs
diff options
context:
space:
mode:
Diffstat (limited to 'fig-web/src/Fig/Web/Module/Bells.hs')
-rw-r--r--fig-web/src/Fig/Web/Module/Bells.hs26
1 files changed, 26 insertions, 0 deletions
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