aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-11-22 23:13:06 +1100
committerYuchen Pei <hi@ypei.me>2022-11-22 23:13:06 +1100
commit55d1e6c9a9f41394a37b48c42f65cc02274b9ab7 (patch)
tree6d8d2763f69eb39c07cb63888b1516660ea7aa1d
initial commit
-rw-r--r--.gitignore2
-rw-r--r--app/Main.hs40
-rw-r--r--librejserver.cabal16
3 files changed, 58 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dc18e40
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*~
+dist-newstyle \ No newline at end of file
diff --git a/app/Main.hs b/app/Main.hs
new file mode 100644
index 0000000..94da226
--- /dev/null
+++ b/app/Main.hs
@@ -0,0 +1,40 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE TypeOperators #-}
+module Main where
+
+import Data.Proxy ( Proxy(..) )
+import Data.Text ( Text )
+import qualified Data.Text as T
+import Network.Wai.Handler.Warp ( run )
+import Servant ( (:>)
+ , Application
+ , CaptureAll
+ , Get
+ , Handler
+ , JSON
+ , Server
+ , serve
+ )
+
+type API = GetPageCompliance
+
+type GetPageCompliance = CaptureAll "url" Text :> Get '[JSON] Text
+
+server :: Server API
+server = getPageCompliance
+
+getPageCompliance :: [Text] -> Handler Text
+getPageCompliance url =
+ return
+ $ "You have requested librejs-compliance info for "
+ <> T.intercalate "/" url
+
+app :: Application
+app = serve api server
+
+api :: Proxy API
+api = Proxy
+
+main :: IO ()
+main = run 5678 app
diff --git a/librejserver.cabal b/librejserver.cabal
new file mode 100644
index 0000000..581d36f
--- /dev/null
+++ b/librejserver.cabal
@@ -0,0 +1,16 @@
+cabal-version: 2.4
+name: librejserver
+version: 0.1.0.0
+synopsis: A server program serving librejs compliance info for webpages.
+description: The program returns the librejs report for a given webpage.
+license: AGPL-3.0-or-later
+author: Yuchen Pei
+maintainer: id@ypei.org
+copyright: 2022 Yuchen Pei
+extra-source-files: CHANGELOG.md
+
+executable librejserver
+ main-is: Main.hs
+ build-depends: base, servant-server, text, warp
+ hs-source-dirs: app
+ default-language: Haskell2010