diff options
| author | LLLL Colonq <llll@colonq> | 2024-01-23 17:07:01 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-01-23 17:07:01 -0500 |
| commit | 4a7ab38bf416fc5eb6f7602cc97146f9b06ec627 (patch) | |
| tree | 0c71b9c45894d049123c1a53e9f5ca13997a99f6 | |
| parent | f7cd8abb5eda335c7c2beb66fd28d594e3f3b956 (diff) | |
Add songs endpoint to API
| -rw-r--r-- | fig-frontend/src/Fig/Frontend.hs | 5 | ||||
| -rw-r--r-- | fig-frontend/src/Fig/Frontend/DB.hs | 4 | ||||
| -rw-r--r-- | flake.nix | 32 |
3 files changed, 29 insertions, 12 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 @@ -6,19 +6,24 @@ outputs = { self, nixpkgs }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; - haskellPackages = pkgs.haskell.packages.ghc94.override { - overrides = self: super: { - discord-haskell = self.callCabal2nix "discord-haskell" ./deps/discord-haskell {}; - irc-conduit = self.callCabal2nix "irc-conduit" ./deps/irc-conduit {}; - irc-client = self.callCabal2nix "irc-client" ./deps/irc-client {}; - fig-utils = self.callCabal2nix "fig-utils" ./fig-utils {}; - fig-bus = self.callCabal2nix "fig-bus" ./fig-bus {}; - fig-monitor-discord = self.callCabal2nix "fig-monitor-discord" ./fig-monitor-discord {}; - fig-monitor-irc = self.callCabal2nix "fig-monitor-irc" ./fig-monitor-irc {}; - fig-monitor-bullfrog = self.callCabal2nix "fig-monitor-bullfrog" ./fig-monitor-bullfrog {}; - fig-bridge-irc-discord = self.callCabal2nix "fig-bridge-irc-discord" ./fig-bridge-irc-discord {}; - fig-frontend = self.callCabal2nix "fig-frontend" ./fig-frontend {}; + overrides = self: super: { + discord-haskell = self.callCabal2nix "discord-haskell" ./deps/discord-haskell {}; + irc-conduit = self.callCabal2nix "irc-conduit" ./deps/irc-conduit {}; + irc-client = self.callCabal2nix "irc-client" ./deps/irc-client {}; + fig-utils = self.callCabal2nix "fig-utils" ./fig-utils {}; + fig-bus = self.callCabal2nix "fig-bus" ./fig-bus {}; + fig-monitor-discord = self.callCabal2nix "fig-monitor-discord" ./fig-monitor-discord {}; + fig-monitor-irc = self.callCabal2nix "fig-monitor-irc" ./fig-monitor-irc {}; + fig-monitor-bullfrog = self.callCabal2nix "fig-monitor-bullfrog" ./fig-monitor-bullfrog {}; + fig-bridge-irc-discord = self.callCabal2nix "fig-bridge-irc-discord" ./fig-bridge-irc-discord {}; + fig-bless = self.callCabal2nix "fig-bless" ./fig-bless {}; + fig-frontend = self.callCabal2nix "fig-frontend" ./fig-frontend {}; }; + haskellPackages = pkgs.haskell.packages.ghc94.override { + inherit overrides; + }; + haskellPackagesStatic = pkgs.pkgsStatic.haskell.packages.ghc94.override { + inherit overrides; }; figBusModule = { config, lib, ... }: let @@ -222,6 +227,7 @@ fig-monitor-irc fig-monitor-bullfrog fig-bridge-irc-discord + fig-bless fig-frontend ]; withHoogle = true; @@ -236,6 +242,8 @@ figMonitorIRC = haskellPackages.fig-monitor-irc; figMonitorBullfrog = haskellPackages.fig-monitor-bullfrog; figBridgeIRCDiscord = haskellPackages.fig-bridge-irc-discord; + figBless = haskellPackages.fig-bless; + figBlessStatic = haskellPackagesStatic.fig-bless; figFrontend = haskellPackages.fig-frontend; }; apps.x86_64-linux.default = { |
