# roads-intersection

> A tool to manage many instances of roads.js

Latest version **0.5.0** (published 2015-12-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install roads-intersection
pnpm add roads-intersection
yarn add roads-intersection
bun add roads-intersection
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2015-12-04 |
| First published | 2015-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Aaron Hedges |
| Maintainers | dashron |

## Links

- npm: https://www.npmjs.com/package/roads-intersection
- Repository: https://github.com/Dashron/roads-intersection
- Homepage: https://github.com/Dashron/roads-intersection#readme
- Issues: https://github.com/Dashron/roads-intersection/issues
- npm.io page: https://npm.io/package/roads-intersection

## Dependencies (3)

- [roads](https://npm.io/package/roads.md) 3.6.0
- [cookie](https://npm.io/package/cookie.md) 0.1.3
- [co-body](https://npm.io/package/co-body.md) 2.0.0

## Recent versions

- 0.5.0 (latest) — 2015-12-04
- 0.4.0 — 2015-11-27
- 0.3.2 — 2015-09-30
- 0.3.1 — 2015-09-11
- 0.3.0 — 2015-09-11
- 0.2.0 — 2015-09-11
- 0.1.0 — 2015-09-10

## README

# 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

---
_Source: https://npm.io/package/roads-intersection · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
