diff options
| author | LLLL Colonq <llll@colonq> | 2025-05-26 04:43:38 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-05-26 04:45:07 -0400 |
| commit | 1f2e453d0c9f8412b9032cb4e655713ecdcf1fa3 (patch) | |
| tree | c2e19550aeec4c092dceefb37a85497a4b90b485 /fig-web/src/Fig/Web/Module/Misc.hs | |
| parent | b5003a97d3f02b7c8cb5e63468b781d8d849264d (diff) | |
web: Refactor major style
Diffstat (limited to 'fig-web/src/Fig/Web/Module/Misc.hs')
| -rw-r--r-- | fig-web/src/Fig/Web/Module/Misc.hs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fig-web/src/Fig/Web/Module/Misc.hs b/fig-web/src/Fig/Web/Module/Misc.hs new file mode 100644 index 0000000..b193314 --- /dev/null +++ b/fig-web/src/Fig/Web/Module/Misc.hs @@ -0,0 +1,38 @@ +module Fig.Web.Module.Misc + ( public + ) where + +import Fig.Prelude + +import System.Random (randomRIO) + +import Control.Lens ((^?), Ixed (..)) + +import Fig.Web.Utils +import Fig.Web.Types +import qualified Fig.Web.DB as DB + +public :: Module +public a = do + onGet "/api/motd" do + DB.get a.db "motd" >>= \case + Nothing -> respondText "" + Just val -> respondText $ decodeUtf8 val + onGet "/api/catchphrase" do + let catchphrases = + [ "vtuber (male)" + , "man of letters" + , "cool guy, online" + , "internet clown man" + , "professional emacs fan" + , "web freak" + , "guy who really likes programming" + , "i use nixos btw" + , "(are these funny or cringe or both?)" + , "haha yay" + , "Joel" + ] :: [Text] + i <- randomRIO (0, length catchphrases - 1) + case catchphrases ^? ix i of + Nothing -> respondText "man of letters" + Just val -> respondText val |
