This package has been deprecated

Author message:

this package has been deprecated

roads-intersection

0.5.0 • Public • Published

roads-intersection

A library to help manage multiple roads, and create servers if necessary.

Intersection

An object that helps manage many roads, and build servers

Intersection (roads, enable_logging)

Constructs an intersection object, to help maintain many roads

buildKoaServer (road_name, error_handler)

Constructs and returns a Koa server, sending all routes through the provided road

buildNodeServer (road_name, error_handler)

Constructs and returns a standard HTTPServer, sending all routes through the provided road

getRoad (road_name)

Returns a single road object associated with this intersection

getAllRoads ()

Returns all roads associated with this intersection

roads_middleware

Contains additional useful middleware to be used with roads.

applyToContext(key, fn)

Applies the function fn to the request context with the name key

cookie ()

Adds methods to make it easy to work with cookies.

The request context will have a cookie object (this.cookie) which contains the request cookie. The response object will have two new methods (this.Response).

  • Response.cookie(cookie) Assigns cookie data to be used by the parent server. Currently only supported by the koa server
  • Response.getCookies() Returns all cookies set to this Response object

reroute (key, road)

Adds methods to allow one road to directly interact with another.

If there is an auth cookie, it will be passed into the road via the Authorization header as if it were OAuth 2. Specifically Authorization: bearer {token}

koa_middleware

Contains additional useful middleware to be used with koa

error (handler, enable_logging)

Adds roads-based error handling to koa

body ()

Parses the body and applies it to the request object

Specifically, the body is applied to this.request.body. Additionally, if the method is POST, and the body contains _method, it will override the http method with the provided method. This allows you to use delete, patch and put methods in html forms.

roadsrouter (road, enable_logging)

Routes all requests through a road

examples

For additional examples, check out the examples folder. Index.js is a working implementation that requires three additional libraries. cookie, koa and roads.

todo:

  • tests
  • examples of reroute middleware
  • examples of standard node server

Readme

Keywords

none

Package Sidebar

Install

npm i roads-intersection

Weekly Downloads

6

Version

0.5.0

License

MIT

Last publish

Collaborators

  • dashron