Skip to content

Commit

Permalink
feat(plugin): plugin to serve static files (#1753)
Browse files Browse the repository at this point in the history
* feat: another file serving plugin
  • Loading branch information
rajatkumar committed Mar 4, 2019
1 parent 0700cfd commit a67b25f
Show file tree
Hide file tree
Showing 16 changed files with 1,501 additions and 467 deletions.
82 changes: 53 additions & 29 deletions docs/_api/formatters.md
Expand Up @@ -7,14 +7,14 @@ permalink: /docs/formatters-api/

### Table of Contents

- [Usage](#usage)
- [Types](#types)
- [formatter](#formatter)
- [Included formatters](#included-formatters)
- [formatText](#formattext)
- [formatJSON](#formatjson)
- [formatJSONP](#formatjsonp)
- [formatBinary](#formatbinary)
- [Usage][1]
- [Types][2]
- [formatter][3]
- [Included formatters][4]
- [formatText][5]
- [formatJSON][6]
- [formatJSONP][7]
- [formatBinary][8]

## Usage

Expand Down Expand Up @@ -48,15 +48,15 @@ var server = restify.createServer({

Format a response for being sent over the wire

Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
Type: [Function][9]

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object (not used)
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body to format
- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body to format

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** formatted response data
Returns **[String][11]** formatted response data

## Included formatters

Expand All @@ -71,12 +71,12 @@ exists. If it doesn't, then the response is a zero-length string.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object (not used)
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body. If it has a toString() method this
- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body. If it has a toString() method this
will be used to make the string representation

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data
Returns **[String][11]** data

### formatJSON

Expand All @@ -85,11 +85,11 @@ exist then a JSON.stringify will be attempted.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object (not used)
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body
- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data
Returns **[String][11]** data

### formatJSONP

Expand All @@ -98,20 +98,44 @@ Unicode escapes line and paragraph separators.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body
- `req` **[Object][10]** the request object
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data
Returns **[String][11]** data

### formatBinary

Binary formatter.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body
- `req` **[Object][10]** the request object
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body

Returns **[Buffer](https://nodejs.org/api/buffer.html)** body
Returns **[Buffer][12]** body

[1]: #usage

[2]: #types

[3]: #formatter

[4]: #included-formatters

[5]: #formattext

[6]: #formatjson

[7]: #formatjsonp

[8]: #formatbinary

[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[12]: https://nodejs.org/api/buffer.html

0 comments on commit a67b25f

Please sign in to comment.