diff --git a/app/Main.hs b/app/Main.hs index d4379ac395df388da6dfab75b440bbd699056236..f0c5b6052d5c360e5f5bbaaec48fee9dc48001ef 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -3,7 +3,5 @@ module Main ) where import PaymentServer.Main - ( run + ( main -- re-export ) - -main = run diff --git a/src/PaymentServer/Main.hs b/src/PaymentServer/Main.hs index 1e3a2f08aa306c5234bfb5272ed1cb937ae78b04..060502baef9334f81e4602d1b9b6523ca6a9cff8 100644 --- a/src/PaymentServer/Main.hs +++ b/src/PaymentServer/Main.hs @@ -1,6 +1,40 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeOperators #-} + module PaymentServer.Main - ( run + ( main ) where -run :: IO () -run = +import Servant + ( Proxy(Proxy) + , Server + , Application + , serve + , (:>) + ) +import Network.Wai.Handler.Warp + ( run + ) +import PaymentServer.Persistence + ( VoucherDatabase + , memory + ) +import PaymentServer.Processors.Stripe + ( StripeAPI + , stripeServer + ) + +type PaymentServerAPI = "v1" :> "stripe" :> StripeAPI + +paymentServer :: VoucherDatabase d => d -> Server PaymentServerAPI +paymentServer = stripeServer + +paymentServerAPI :: Proxy PaymentServerAPI +paymentServerAPI = Proxy + +paymentServerApp :: VoucherDatabase d => d -> Application +paymentServerApp = (serve paymentServerAPI) . paymentServer + +main :: IO () +main = memory >>= return . paymentServerApp >>= run 8081