chakra-0.1.0: A REST Web Api server template for building (micro)services.
Safe HaskellTrustworthy
LanguageHaskell2010

Chakra

Description

This module re-exports all functionality of this package for easy use. Users expected to import this module only.

Examples:

import Chakra

Getting started

To create a bare minimum API service all you need is below:

#!/usr/bin/env stack
{- stack --resolver lts-14.27 runghc --package chakra -}
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings, UnicodeSyntax, DataKinds, TypeOperators #-}
import RIO
import Chakra
import Servant

type HelloRoute = "hello" :> QueryParam "name" Text :> Get '[PlainText] Text
type API = HelloRoute :| EmptyAPI

hello :: Maybe Text -> BasicApp Text
hello name = do
  let name' = fromMaybe "Sensei!" name
  logInfo $ "Saying hello to " <> display name'
  return $ "Hello " <> name' <> "!"

main :: IO ()
main = do
  let infoDetail = InfoDetail "example" "dev" "0.1" "change me"
      appEnv = appEnvironment infoDetail
      appVer = appVersion infoDetail
      appAPI = Proxy :: Proxy API
      appServer = hello :| emptyServer
  logFunc <- buildLogger appEnv appVer
  middlewares <- chakraMiddlewares infoDetail
  runChakraAppWithMetrics
    middlewares
    EmptyContext
    (logFunc, infoDetail)
    appAPI
    appServer
Synopsis

Documentation

module Chakra.App

Configuration reading from ENV utility functions

JWT based authentication functionalities

module Chakra.JWT

Logging related functionalities

Package defined Types

Assorted conventient functions

type BasicApp = RIO BasicAppCtx Source #

Nice type synonym to mark your servant handlers For real life you need to create one for your application

type BasicAppCtx = (ModLogger, InfoDetail) Source #

Basic application context, mostly used in examples. For real life you need to create one for your application