summaryrefslogtreecommitdiff
path: root/fig-frontend/src/Fig
diff options
context:
space:
mode:
Diffstat (limited to 'fig-frontend/src/Fig')
-rw-r--r--fig-frontend/src/Fig/Frontend.hs5
-rw-r--r--fig-frontend/src/Fig/Frontend/DB.hs4
2 files changed, 9 insertions, 0 deletions
diff --git a/fig-frontend/src/Fig/Frontend.hs b/fig-frontend/src/Fig/Frontend.hs
index aff74c8..95ab28b 100644
--- a/fig-frontend/src/Fig/Frontend.hs
+++ b/fig-frontend/src/Fig/Frontend.hs
@@ -14,6 +14,7 @@ import qualified Web.Twain as Tw
import qualified Lucid as L
import qualified Lucid.Base as L
+import Fig.Utils.SExpr
import Fig.Frontend.Utils
import Fig.Frontend.Auth
import Fig.Frontend.State
@@ -55,4 +56,8 @@ app cfg = do
DB.get db ("user:" <> encodeUtf8 name) >>= \case
Nothing -> Tw.send . Tw.status Tw.status404 $ Tw.text "user not found"
Just val -> Tw.send . Tw.text $ decodeUtf8 val
+ , Tw.get "/api/songs" do
+ DB.hvals db "songnames" >>= \case
+ Nothing -> Tw.send . Tw.status Tw.status404 $ Tw.text "no sounds found :("
+ Just songs -> Tw.send . Tw.text . pretty . SExprList @Void $ SExprString . decodeUtf8 <$> songs
]
diff --git a/fig-frontend/src/Fig/Frontend/DB.hs b/fig-frontend/src/Fig/Frontend/DB.hs
index 0425f67..0ae8058 100644
--- a/fig-frontend/src/Fig/Frontend/DB.hs
+++ b/fig-frontend/src/Fig/Frontend/DB.hs
@@ -15,3 +15,7 @@ get :: MonadIO m => Redis.Connection -> ByteString -> m (Maybe ByteString)
get c key = liftIO $ Redis.runRedis c do
v <- Redis.get key
pure $ join $ hush v
+
+hvals :: MonadIO m => Redis.Connection -> ByteString -> m (Maybe [ByteString])
+hvals c key = liftIO $ Redis.runRedis c do
+ hush <$> Redis.hvals key