{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}

module Spm.Server.UI
  ( uiServer
  ) where

import Prelude

import Network.Wai

import Network.Wai.Application.Static
import WaiAppStatic.Types

import Data.FileEmbed


uiServer :: Application
uiServer = staticApp settings
    { ssLookupFile = \pcs -> ssLookupFile settings pcs >>= \case
        LRNotFound -> ssLookupFile settings [unsafeToPiece "index.html"]
        o -> return o
    }
  where settings = embeddedSettings $(embedDir "frontend")