aboutsummaryrefslogtreecommitdiff
path: root/server/default-conf/Main.hs
blob: 35088e88ed67933e76358a42f03c213fe6bd1a38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE ImpredicativeTypes #-}

module Main (main) where

import Thermoprint.Server

import Thermoprint.Server.Printer.Debug
import Thermoprint.Server.Printer.Debug.Delayed

import Control.Monad.Trans.Resource
import Control.Monad.Logger
import Control.Monad.Reader

import Database.Persist.Sqlite

main :: IO ()
main = thermoprintServer True (Nat runSqlite) $ def `withPrinters` printers
  where
    runSqlite :: ReaderT ConnectionPool (LoggingT IO) a -> IO a
    runSqlite = runStderrLoggingT . withSqlitePool "thermoprint.sqlite" 1 . runReaderT

    printers :: [( ResourceT (ReaderT ConnectionPool (LoggingT IO)) PrinterMethod
                 , QMConfig (ResourceT (ReaderT ConnectionPool (LoggingT IO)))
                 )
                ]
    printers = [ (pure debugPrint, def)
               , (pure $ delayedDebugPrint (10 * 10^6), def)
               ]