Main.hs (1217B)
1 module Main ( main ) where 2 3 import qualified Core.Configuration as Configuration 4 import qualified Core.HTTP as HTTP 5 import qualified Core.SQLite as DB 6 import Core.Types 7 8 import Crypto.Saltine (sodiumInit) 9 import GHC.Natural (popCountNatural) 10 import Prelude hiding (id) 11 import Web.Scotty 12 13 -- Purr's entrypoint 14 main :: IO () 15 main = do 16 -- Initialize the RNG used for sodium encryption (Saltine library) 17 sodiumInit 18 {- Initialize our dotenv configuration which reads from a .env configuration 19 if any required variables are missing from the provided environment -} 20 Configuration.init 21 {- Initialize the encryption key file if it doesn't 22 exist yet or use the existing key -} 23 Configuration.keyFileInit 24 {- Initialize our database by ensuring the SQLite file exists 25 and has tables setup as the application expects -} 26 DB.init 27 {- Get the configured port to run on and start the Scotty webserver app 28 defined in HTTP.app -} 29 port <- Configuration.appPort 30 env <- Configuration.getRuntimeEnvironment 31 scotty (read port) (HTTP.app env)