Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ if (!process.env.NO_LINT) {
config.rules['func-names'] = ERROR;
config.rules['block-scoped-var'] = ERROR;
config.rules['consistent-return'] = ERROR;
config.rules['curly'] = OFF;
config.rules.curly = OFF;
config.rules['default-case'] = ERROR;
config.rules['dot-notation'] = [ERROR, { allowKeywords: true }];
config.rules['eqeqeq'] = ERROR;
config.rules.eqeqeq = ERROR;
config.rules['guard-for-in'] = ERROR;
config.rules['no-alert'] = ERROR;
config.rules['no-caller'] = ERROR;
Expand Down Expand Up @@ -99,11 +99,11 @@ if (!process.env.NO_LINT) {

config.rules['no-warning-comments'] = [1];
config.rules['no-with'] = ERROR;
config.rules['radix'] = ERROR;
config.rules.radix = ERROR;
config.rules['wrap-iife'] = ERROR;

// strict mode
config.rules['strict'] = [ERROR, 'global'];
config.rules.strict = [ERROR, 'global'];

// variables
config.rules['no-catch-shadow'] = ERROR;
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install node v16
uses: actions/setup-node@v1
- uses: actions/checkout@v4
- name: install node v26
uses: actions/setup-node@v4
with:
node-version: v16.x
node-version: v26.x
- name: install dependencies
run: npm install
- name: check lint
Expand All @@ -28,15 +28,14 @@ jobs:
os:
- ubuntu-latest
node-version:
- 14.x
- 16.x
- 18.x
- 20.x
- 22.x
- 24.x
- 26.x
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- name: use node ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
- name: install dependencies
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ benchmark/results
.nyc_output/
coverage/
cover_html/
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $ npm install restify

## Supported Node Versions

Restify currently works on Node.js v14.x and v16.x.
Restify currently works on Node.js v22.x, v24.x and v26.x.

## License

Expand Down
5 changes: 3 additions & 2 deletions benchmark/benchmarks/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ for (var j = 0; j < 10; j++) {
server.use(handler);
}

server.get(path, function get(req, res) {
server.get(path, function get(req, res, next) {
res.send('hello world');
next();
});

if (!module.parent) {
if (require.main === module) {
server.listen(port);
}
5 changes: 3 additions & 2 deletions benchmark/benchmarks/response-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ module.exports = {
url: 'http://localhost:' + port + path
};

server.get(path, function onRequest(req, res) {
server.get(path, function onRequest(req, res, next) {
res.send({ hello: 'world' });
next();
});

if (!module.parent) {
if (require.main === module) {
server.listen(port);
}
5 changes: 3 additions & 2 deletions benchmark/benchmarks/response-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ module.exports = {
url: 'http://localhost:' + port + path
};

server.get(path, function onRequest(req, res) {
server.get(path, function onRequest(req, res, next) {
res.send('hello world');
next();
});

if (!module.parent) {
if (require.main === module) {
server.listen(port);
}
5 changes: 3 additions & 2 deletions benchmark/benchmarks/router-heavy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ var routes = {
}
};

function handler(req, res) {
function handler(req, res, next) {
res.send('hello');
next();
}

function attachRoute(parent, routeConfig) {
Expand All @@ -127,6 +128,6 @@ function attachRoute(parent, routeConfig) {

attachRoute('', routes);

if (!module.parent) {
if (require.main === module) {
server.listen(port);
}
95 changes: 55 additions & 40 deletions docs/_api/formatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ permalink: /docs/formatters-api/
- [Usage][1]
- [Types][2]
- [formatter][3]
- [Included formatters][4]
- [formatText][5]
- [formatJSON][6]
- [formatJSONP][7]
- [formatBinary][8]
- [Parameters][4]
- [Included formatters][5]
- [formatText][6]
- [Parameters][7]
- [formatJSON][8]
- [Parameters][9]
- [formatJSONP][10]
- [Parameters][11]
- [formatBinary][12]
- [Parameters][13]

## Usage

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

Format a response for being sent over the wire

Type: [Function][9]
Type: [Function][14]

**Parameters**
#### Parameters

- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body to format
- `req` **[Object][15]** the request object (not used)
- `res` **[Object][15]** the response object
- `body` **[Object][15]** response body to format

Returns **[String][11]** formatted response data
Returns **[String][16]** formatted response data

## Included formatters

Expand All @@ -69,73 +74,83 @@ use cases.
Formats the body to 'text' by invoking a toString() on the body if it
exists. If it doesn't, then the response is a zero-length string.

**Parameters**
#### Parameters

- `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
- `req` **[Object][15]** the request object (not used)
- `res` **[Object][15]** the response object
- `body` **[Object][15]** response body. If it has a toString() method this
will be used to make the string representation

Returns **[String][11]** data
Returns **[String][16]** data

### formatJSON

JSON formatter. Will look for a toJson() method on the body. If one does not
exist then a JSON.stringify will be attempted.

**Parameters**
#### Parameters

- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body
- `req` **[Object][15]** the request object (not used)
- `res` **[Object][15]** the response object
- `body` **[Object][15]** response body

Returns **[String][11]** data
Returns **[String][16]** data

### formatJSONP

JSONP formatter. like JSON, but with a callback invocation.
Unicode escapes line and paragraph separators.

**Parameters**
#### Parameters

- `req` **[Object][10]** the request object
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body
- `req` **[Object][15]** the request object
- `res` **[Object][15]** the response object
- `body` **[Object][15]** response body

Returns **[String][11]** data
Returns **[String][16]** data

### formatBinary

Binary formatter.

**Parameters**
#### Parameters

- `req` **[Object][10]** the request object
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body
- `req` **[Object][15]** the request object
- `res` **[Object][15]** the response object
- `body` **[Object][15]** response body

Returns **[Buffer][12]** body
Returns **[Buffer][17]** body

[1]: #usage

[2]: #types

[3]: #formatter

[4]: #included-formatters
[4]: #parameters

[5]: #formattext
[5]: #included-formatters

[6]: #formatjson
[6]: #formattext

[7]: #formatjsonp
[7]: #parameters-1

[8]: #formatbinary
[8]: #formatjson

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

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

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

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

[13]: #parameters-4

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

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

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

[17]: https://nodejs.org/api/buffer.html
Loading
Loading