Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.
/ purescript-rest Public archive

A toolkit for creating REST services with Node and PureScript

License

Notifications You must be signed in to change notification settings

paf31/purescript-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-rest

A toolkit for creating REST services with Node and PureScript.

Getting Started

The key functionality is in the REST.Endpoint module, which defines the Endpoint type class:

class (Applicative e) <= Endpoint e

This type class can be used to parse routes, read query parameters and headers, read the request body using purescript-foreign, and get a callback with which to return a response.

This lets us define routes in an applicative style, as follows:

endpoint :: forall e eff. (Endpoint e) => e (Eff (http :: Node.HTTP | eff) Unit)
endpoint = getProductDetails <$> (get *> lit "product" *> match "id" "Product ID") <*> lit "details"

Using a type class allows us to interpret our routes in different ways:

  • As an actual web service
  • As documentation, including an automatically-generated API tester.

See the test project for a worked example.

About

A toolkit for creating REST services with Node and PureScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published