Module

Payload.Spec

Package
purescript-payload
Repository
hoodunit/purescript-payload

This module contains all of the types and kinds that can appear in an API spec.

#Spec Source

data Spec apiSpec

Wrapper for writing type-level specs

Constructors

#Route Source

data Route (method :: Symbol) (path :: Symbol) spec

Type-level representation of an endpoint route, meant to be used in combination with the method convenience types.

Examples:

GET "/api/user/<id>"
DELETE "/api/posts/<..rest>"

Constructors

#GET Source

type GET = Route "GET"

#HEAD Source

type HEAD = Route "HEAD"

#POST Source

type POST = Route "POST"

#PUT Source

type PUT = Route "PUT"

#DELETE Source

type DELETE = Route "DELETE"

#Routes Source

data Routes (path :: Symbol) routesSpec

Defines a type-level parent route. Takes a path, which is prepended to all child routes, and a spec, which must be a type-level record. If the path contains named URL parameters, the types of those parameters must be given in the params field of the spec record. Can optionally contain a guards field with a list of guards to run before calling child routes. All other fields are treated as endpoint routes or sub-parent routes.

Example:

Routes "/users/<userId>" {
  guards :: Guards ("apiKey" : Nil),
  params :: { userId :: Int },
  posts :: GET "/posts" {
    response :: UserPosts
  }
}

Constructors

#Guards Source

data Guards (g :: GuardList)

Type-level list of guard names that will be run before calling a route or child routes.

Constructors

#GuardList Source

data GuardList :: Type

#GNil Source

data GNil :: GuardList

#type (:) Source

Operator alias for Payload.Spec.GCons (right-associative / precedence 1)

#Nil Source

type Nil = GNil