Moved API definition out into ApiTypes.hs
authorsabadev <saba@sabadev.xyz>
Sun, 21 Mar 2021 04:31:11 +0000 (00:31 -0400)
committersabadev <dev@sabadev.xyz>
Tue, 13 Apr 2021 01:16:30 +0000 (21:16 -0400)
src/ApiTypes.hs [new file with mode: 0644]
src/Server.hs

diff --git a/src/ApiTypes.hs b/src/ApiTypes.hs
new file mode 100644 (file)
index 0000000..e0a68c6
--- /dev/null
@@ -0,0 +1,17 @@
+module ApiTypes where
+
+import CssContentType
+import Html
+import Lucid
+import Servant
+import Servant.HTML.Lucid (HTML(..))
+import qualified Clay as C
+
+type Api = Page :<|> Themes
+type Page = MainPage :<|> BlogPost
+type MainPage = ThemeParam :> Get '[HTML] (Html ())
+type BlogPost = ThemeParam :> Capture "id" BlogId :> Get '[HTML] (Html ())
+type Themes = "style" :> (DarkTheme :<|> LightTheme)
+type DarkTheme = "dark" :> QueryParam "red" Integer :> QueryParam "green" Integer :> QueryParam "blue" Integer :> Get '[CSS] C.Css
+type LightTheme = "light" :> QueryParam "red" Integer :> QueryParam "green" Integer :> QueryParam "blue" Integer :> Get '[CSS] C.Css
+type ThemeParam = QueryParam "theme" Theme
index f1b7fff..c3d0fbe 100644 (file)
@@ -1,14 +1,13 @@
 module Server where
 
+import ApiTypes
 import Control.Monad ((<=<))
 import Control.Monad.IO.Class (liftIO)
-import CssContentType
 import Data.Maybe (fromMaybe)
 import Html
 import Lucid
 import RenderBlog (renderBlog)
 import Servant
-import Servant.HTML.Lucid (HTML(..))
 import StyleSheet
 import qualified Clay as C
 import qualified Data.Text as T
@@ -20,15 +19,6 @@ app = serve apiProxy api
 apiProxy :: Proxy Api
 apiProxy = Proxy
 
-type Api = Page :<|> Themes
-type Page = MainPage :<|> BlogPost
-type MainPage = ThemeParam :> Get '[HTML] (Html ())
-type BlogPost = ThemeParam :> Capture "id" BlogId :> Get '[HTML] (Html ())
-type Themes = "style" :> (DarkTheme :<|> LightTheme)
-type DarkTheme = "dark" :> QueryParam "red" Integer :> QueryParam "green" Integer :> QueryParam "blue" Integer :> Get '[CSS] C.Css
-type LightTheme = "light" :> QueryParam "red" Integer :> QueryParam "green" Integer :> QueryParam "blue" Integer :> Get '[CSS] C.Css
-type ThemeParam = QueryParam "theme" Theme
-
 api :: Server Api
 api = page :<|> themes