# router-docs

> Adds dynamic documentation to express routes

Latest version **2.1.1** (published 2017-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install router-docs
pnpm add router-docs
yarn add router-docs
bun add router-docs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2017-03-08 |
| First published | 2015-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Pristine Dev Team |
| Maintainers | markpristine, schwing |
| Keywords | express, documentation, docs |

## Links

- npm: https://www.npmjs.com/package/router-docs
- Repository: https://github.com/pristineio/router-docs
- Homepage: https://github.com/pristineio/router-docs#readme
- Issues: https://github.com/pristineio/router-docs/issues
- npm.io page: https://npm.io/package/router-docs

## Dependencies (4)

- [pug](https://npm.io/package/pug.md) ^2.0.0-beta11
- [tv4](https://npm.io/package/tv4.md) ^1.2.7
- [express](https://npm.io/package/express.md) ^4.14.1
- [request](https://npm.io/package/request.md) ^2.80.0

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2017-03-08
- 2.1.0 — 2017-03-07
- 2.0.43 — 2016-12-06
- 2.0.42 — 2016-12-06
- 2.0.41 — 2016-10-03
- 2.0.40 — 2016-04-21
- 2.0.39 — 2016-04-21
- 2.0.37 — 2016-04-21
- 2.0.36 — 2016-04-21
- 2.0.35 — 2016-04-21
- 2.0.34 — 2016-04-21
- 2.0.33 — 2016-04-21
- 2.0.31 — 2016-04-19
- 2.0.30 — 2016-04-12
- 2.0.29 — 2016-04-12
- … 10 more at https://npm.io/package/router-docs/versions

## README

# Router Docs: API extension for express
[![Code Climate](https://codeclimate.com/github/pristineio/router-docs/badges/gpa.svg)](https://codeclimate.com/github/pristineio/router-docs)

This module adds a `docs` method to the express application object, as well as a `/docs` route that renders a Jade template for pretty documentation.

### Usage
```js
var app = express();
require('router-docs')(app);
app.get('/twoHunny', function(req, res) {
  res.status(200).end();
}).docs('Never gonna give you up...');

app.put('/foHunny', function(req, res) {
  res.status(400).end();
}).docs({
  title: 'Fo Hunny Method',
  description: 'Never gonna let you down...'
});

app.post('/juicy/:alpha/fruit/:beta', function(req, res, next) {
  res.status(200).end();
}).docs({
  title: 'Juicy Fruit'
  description: 'Never gonna run around and...',
  // Supply JSON Schema properties in the order of route request parameters
  // See: http://json-schema.org/latest/json-schema-validation.html
  requestBody: {
    fruit: 'Stripe',
    gum: 123
  },
  requestParameters: [
    { // alpha
      type: 'integer',
      minimum: 2,
      maximum: 128
    },
    { //beta
      type: 'string',
      pattern: '^[a-zA-Z0-9]$'
    }
  ]
});
```
### Ideas and TODO
- Supply custom middleware to the constructor, affecting /docs behavior
- Construct `example` properties based on the parameter and body specs of the routes
- Implement `response` field
- Export JSON schemas and/or allow for request/response validation

### License
MIT License
Copyright (c) 2016, [Pristine Inc.](http://pristine.io)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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