From 55d1e6c9a9f41394a37b48c42f65cc02274b9ab7 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 22 Nov 2022 23:13:06 +1100 Subject: initial commit --- .gitignore | 2 ++ app/Main.hs | 40 ++++++++++++++++++++++++++++++++++++++++ librejserver.cabal | 16 ++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 .gitignore create mode 100644 app/Main.hs create mode 100644 librejserver.cabal 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 -- cgit v1.2.3