summaryrefslogtreecommitdiff
path: root/hosts/surtr/email/spm/lib/Spm/Api.hs
blob: d9644222f55613300577e2e4ad934274626a137c (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
30
31
32
33
34
35
36
37
38
39
40
{-# LANGUAGE TemplateHaskell #-}

module Spm.Api
  ( SpmMailbox
  , SpmApi, spmApi
  ) where

import Prelude

import Servant.API

import Data.Proxy (Proxy(..))

import Data.Text (Text)

import GHC.Generics (Generic)
import Type.Reflection (Typeable)

import Control.Lens.TH

import Data.CaseInsensitive (CI)
import Data.CaseInsensitive.Instances ()

import Crypto.JOSE.JWK (JWKSet)

import Data.UUID (UUID)
import Data.UUID.Instances ()


newtype SpmMailbox = SpmMailbox { unSpmMailbox :: CI Text }
  deriving stock (Eq, Ord, Read, Show, Generic, Typeable)
  deriving newtype (MimeRender JSON, MimeRender PlainText)
makeWrapped ''SpmMailbox

type SpmApi = "whoami" :> Get '[PlainText, JSON] SpmMailbox
         :<|> ".well-known" :> "jwks.json" :> Get '[JSON] JWKSet
         :<|> "instance-id" :> Get '[PlainText, JSON, OctetStream] UUID

spmApi :: Proxy SpmApi
spmApi = Proxy