module Servant.OAuth2.Examples.Config where import "text" Data.Text (Text) import "tomland" Toml (TomlCodec, diwrap, table, text, (.=)) data OAuthConfig = OAuthConfig { OAuthConfig -> Text _name :: Text , OAuthConfig -> Text _id :: Text , OAuthConfig -> Text _secret :: Text , OAuthConfig -> Text _callbackUrl :: Text } oauthConfigCodec :: TomlCodec OAuthConfig oauthConfigCodec :: TomlCodec OAuthConfig oauthConfigCodec = Text -> Text -> Text -> Text -> OAuthConfig OAuthConfig (Text -> Text -> Text -> Text -> OAuthConfig) -> Codec OAuthConfig Text -> Codec OAuthConfig (Text -> Text -> Text -> OAuthConfig) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> TomlCodec Text -> TomlCodec Text forall b a. Coercible a b => TomlCodec a -> TomlCodec b diwrap (Key -> TomlCodec Text text Key "name") TomlCodec Text -> (OAuthConfig -> Text) -> Codec OAuthConfig Text forall field a object. Codec field a -> (object -> field) -> Codec object a .= OAuthConfig -> Text _name Codec OAuthConfig (Text -> Text -> Text -> OAuthConfig) -> Codec OAuthConfig Text -> Codec OAuthConfig (Text -> Text -> OAuthConfig) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> TomlCodec Text -> TomlCodec Text forall b a. Coercible a b => TomlCodec a -> TomlCodec b diwrap (Key -> TomlCodec Text text Key "id") TomlCodec Text -> (OAuthConfig -> Text) -> Codec OAuthConfig Text forall field a object. Codec field a -> (object -> field) -> Codec object a .= OAuthConfig -> Text _id Codec OAuthConfig (Text -> Text -> OAuthConfig) -> Codec OAuthConfig Text -> Codec OAuthConfig (Text -> OAuthConfig) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> TomlCodec Text -> TomlCodec Text forall b a. Coercible a b => TomlCodec a -> TomlCodec b diwrap (Key -> TomlCodec Text text Key "secret") TomlCodec Text -> (OAuthConfig -> Text) -> Codec OAuthConfig Text forall field a object. Codec field a -> (object -> field) -> Codec object a .= OAuthConfig -> Text _secret Codec OAuthConfig (Text -> OAuthConfig) -> Codec OAuthConfig Text -> TomlCodec OAuthConfig forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> TomlCodec Text -> TomlCodec Text forall b a. Coercible a b => TomlCodec a -> TomlCodec b diwrap (Key -> TomlCodec Text text Key "callback_url") TomlCodec Text -> (OAuthConfig -> Text) -> Codec OAuthConfig Text forall field a object. Codec field a -> (object -> field) -> Codec object a .= OAuthConfig -> Text _callbackUrl data Config = Config { Config -> OAuthConfig _githubOAuth :: OAuthConfig , Config -> OAuthConfig _googleOAuth :: OAuthConfig } configCodec :: TomlCodec Config configCodec :: TomlCodec Config configCodec = OAuthConfig -> OAuthConfig -> Config Config (OAuthConfig -> OAuthConfig -> Config) -> Codec Config OAuthConfig -> Codec Config (OAuthConfig -> Config) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> TomlCodec OAuthConfig -> Key -> TomlCodec OAuthConfig forall a. TomlCodec a -> Key -> TomlCodec a table TomlCodec OAuthConfig oauthConfigCodec Key "oauth-github" TomlCodec OAuthConfig -> (Config -> OAuthConfig) -> Codec Config OAuthConfig forall field a object. Codec field a -> (object -> field) -> Codec object a .= Config -> OAuthConfig _githubOAuth Codec Config (OAuthConfig -> Config) -> Codec Config OAuthConfig -> TomlCodec Config forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> TomlCodec OAuthConfig -> Key -> TomlCodec OAuthConfig forall a. TomlCodec a -> Key -> TomlCodec a table TomlCodec OAuthConfig oauthConfigCodec Key "oauth-google" TomlCodec OAuthConfig -> (Config -> OAuthConfig) -> Codec Config OAuthConfig forall field a object. Codec field a -> (object -> field) -> Codec object a .= Config -> OAuthConfig _googleOAuth