<commit_before>Respectify
==========

> Route specification for [restify](http://mcavage.me/node-restify/)

[![Build Status](https://secure.travis-ci.org/majorleaguesoccer/respectify.png)](http://travis-ci.org/majorleaguesoccer/respectify) 
[![devDependency Status](https://david-dm.org/majorleaguesoccer/respectify.png)](https://david-dm.org/majorleaguesoccer/respectify#info=dependencies)
[![NPM version](https://badge.fury.io/js/respectify.png)](http://badge.fury.io/js/respectify)


### Table of Contents

* [Install](#install)
* [Usage](#usage)
* [Parameters](#parameters)
* [Parameter Targeting](#parameter-targeting)
* [API](#api)
  - [constructor](#new-respectifyserver-options)
  - [middleware](#instancemiddlewareoptions)
  - [getSpecByRoute](#instancegetspecbyrouteroute)
  - [getDefaults](#instancegetdefaultspath-version)
  - [loadSpecs](#instanceloadspecsversion)
  - [findRoutes](#instancefindroutespath-version)
  - [findSpecs](#instancefindspecspath-version)
  - [getVersions](#instancegetversions)
  - [getRouteParams](#instancegetrouteparamspath-version)
  - [getMergedParams](#instancegetmergedparamspath-version-params)
* [Debugging](#debugging)
* [License](#license)


Install
-------

With [npm](https://npmjs.org)

```
npm install respectify
```


Usage
-----

```js
var restify = require('restify')
  , Respectify = require('respectify')
 
// Create the restify server
var server = restify.createServer()
 
server.get({
  path: '/things/:id'
, version: '1.0.0'
, params: {
    id: 'number'
  , another: {
      dataTypes: ['number', 'string']
    , default: 20
    }
  }
}, function(req, res, next) {
  // ...
})
 
// Create the respectify instance with the new server
var respect = new Respectify(server, options)
 
// Add the respectify middleware to validate routes
server.use(respect.middleware)
```


Parameters
----------

A `params` object must be added to the route options in order for Respectify 
to parse and / or validate the route.

* `dataTypes` - one of the following: `number`, `date`, `string`, `array`, `object`, `boolean`
* `default` - the default value to use if the param was not sent, functions can be used
* `dataValues` - array of specific values considered valid
* `min` - minimum value allowed (`number` type only)
* `max` - maximum value allowed (`number` type only)<commit_msg>Fix usage section<commit_after>Respectify
==========

> Route specification for [restify](http://mcavage.me/node-restify/)

[![Build Status](https://secure.travis-ci.org/majorleaguesoccer/respectify.png)](http://travis-ci.org/majorleaguesoccer/respectify) 
[![devDependency Status](https://david-dm.org/majorleaguesoccer/respectify.png)](https://david-dm.org/majorleaguesoccer/respectify#info=dependencies)
[![NPM version](https://badge.fury.io/js/respectify.png)](http://badge.fury.io/js/respectify)


### Table of Contents

* [Install](#install)
* [Usage](#usage)
* [Parameters](#parameters)
* [Parameter Targeting](#parameter-targeting)
* [API](#api)
  - [constructor](#new-respectifyserver-options)
  - [middleware](#instancemiddlewareoptions)
  - [getSpecByRoute](#instancegetspecbyrouteroute)
  - [getDefaults](#instancegetdefaultspath-version)
  - [loadSpecs](#instanceloadspecsversion)
  - [findRoutes](#instancefindroutespath-version)
  - [findSpecs](#instancefindspecspath-version)
  - [getVersions](#instancegetversions)
  - [getRouteParams](#instancegetrouteparamspath-version)
  - [getMergedParams](#instancegetmergedparamspath-version-params)
* [Debugging](#debugging)
* [License](#license)


Install
-------

With [npm](https://npmjs.org)

```
npm install respectify
```


Usage
-----

```js
var restify = require('restify')
  , Respectify = require('respectify')
 
// Create the restify server
var server = restify.createServer()
 
// Create the respectify instance with the new server
var respect = new Respectify(server)
 
// Add the respectify middleware to validate routes
server.use(respect.middleware())

server.get({
  path: '/things/:id'
, version: '1.0.0'
, params: {
    id: 'number'
  , another: {
      dataTypes: ['number', 'string']
    , default: 20
    }
  }
}, function(req, res, next) {
  // ...
}) 
```


Parameters
----------

A `params` object must be added to the route options in order for Respectify 
to parse and / or validate the route.

* `dataTypes` - one of the following: `number`, `date`, `string`, `array`, `object`, `boolean`
* `default` - the default value to use if the param was not sent, functions can be used
* `dataValues` - array of specific values considered valid
* `min` - minimum value allowed (`number` type only)
* `max` - maximum value allowed (`number` type only)
{'fraction_non_alphanumeric': 0.16598668670818123, 'fraction_numerical': 0.002147305132059266, 'mean_word_length': 4.708333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '698016', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1466, 'n_words': 320}