Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restify

Package Overview
Dependencies
Maintainers
6
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restify - npm Package Compare versions

Comparing version 5.0.0-beta-4.0 to 5.0.0-beta-5.0

2

CHANGES.md
# restify Changelog
## 5.0.0
- #1281 Add `server.debugInfo` method, Yunong Xiao, Alex Liu
- #1281 `server.unfinishedRequests()` to `server.inflightRequests()`, Yunong Xiao
- #1256 add `req.id()` method, Alex Liu

@@ -5,0 +7,0 @@ - #1251 add `req.connectionState()` method, Alex Liu

6

lib/request.js

@@ -11,3 +11,3 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved.

var mime = require('mime');
var Negotatior = require('negotiator');
var Negotiator = require('negotiator');
var uuid = require('uuid');

@@ -35,4 +35,4 @@

if (!req._negotatiator) {
req._negotiator = new Negotatior({
if (!req._negotiator) {
req._negotiator = new Negotiator({
headers: {

@@ -39,0 +39,0 @@ accept: h.accept || '*/*',

@@ -9,6 +9,8 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved.

var errors = require('restify-errors');
var assert = require('assert-plus');
var LRU = require('lru-cache');
var Negotiator = require('negotiator');
var _ = require('lodash');
var assert = require('assert-plus');
var cloneRegexp = require('clone-regexp');
var errors = require('restify-errors');
var semver = require('semver');

@@ -191,3 +193,3 @@

// So we can retrun 405 vs 404, we maintain a reverse mapping of URLs
// So we can return 405 vs 404, we maintain a reverse mapping of URLs
// to method

@@ -259,3 +261,3 @@ this.reverse = {};

* @param {Object} options an options object
* @returns {String} returns the route name if creation is successful.
* @returns {String} returns the route name if creation is successful.
*/

@@ -639,1 +641,35 @@ Router.prototype.mount = function mount(options) {

};
/**
* Return information about the routes registered in the router.
* @public
* @returns {object} The routes in the router.
*/
Router.prototype.getDebugInfo = function getRoutes() {
var self = this;
var routeInfo = [];
_.forOwn(self.mounts, function (value, routeName) {
if (self.mounts.hasOwnProperty(routeName)) {
var mountedRoute = self.mounts[routeName];
var routeRegex = mountedRoute.path;
routeInfo.push({
name: mountedRoute.name,
method: mountedRoute.method.toLowerCase(),
input: mountedRoute.spec.path,
compiledRegex: cloneRegexp(routeRegex),
// any url params are saved on the regex object as a key/val
// bucket.
compiledUrlParams: (routeRegex.restifyParams &&
(Object.keys(routeRegex.restifyParams).length > 0)) ?
shallowCopy(routeRegex.restifyParams) : null,
versions: (mountedRoute.versions.length > 1) ?
mountedRoute.versions : null
});
}
});
return routeInfo;
};

@@ -11,4 +11,5 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved.

var _ = require('lodash');
var assert = require('assert-plus');
var errors = require('restify-errors');
var assert = require('assert-plus');
var mime = require('mime');

@@ -273,3 +274,3 @@ var once = require('once');

this.socketio = options.socketio || false;
this._unfinishedRequests = 0;
this._inflightRequests = 0;

@@ -434,2 +435,4 @@ var fmt = mergeFormatters(options.formatters);

Server.prototype.close = function close(callback) {
var self = this;
if (callback) {

@@ -440,2 +443,3 @@ assert.func(callback, 'callback');

this.server.once('close', function onClose() {
self.emit('close');
return (callback ? callback() : false);

@@ -449,10 +453,10 @@ });

/**
* Returns the number of currently unfinished requests.
* Returns the number of currently inflight requests.
* @public
* @function unfinishedRequests
* @function inflightRequests
* @returns {String}
*/
Server.prototype.unfinishedRequests = function unfinishedRequests() {
Server.prototype.inflightRequests = function inflightRequests() {
var self = this;
return (self._unfinishedRequests);
return (self._inflightRequests);
};

@@ -741,3 +745,3 @@

// increment number of requests
self._unfinishedRequests++;
self._inflightRequests++;

@@ -1175,3 +1179,52 @@ function routeAndRun() {

// decrement number of requests
self._unfinishedRequests--;
self._inflightRequests--;
};
/**
* Return debug information about the server.
* @public
* @method debugInfo
* @returns {Object}
*/
Server.prototype.debugInfo = function debugInfo() {
var self = this;
// map an array of function to an array of function names
var funcNameMapper = function funcNameMapper(handler) {
if (handler.name === '') {
return 'anonymous';
} else {
return handler.name;
}
};
if (!self._debugInfo) {
var addressInfo = self.server.address();
// output the actual routes registered with restify
var routeInfo = self.router.getDebugInfo();
// get each route's handler chain
_.forEach(routeInfo, function (value, key) {
var routeName = value.name;
value.handlers = self.routes[routeName].map(funcNameMapper);
});
self._debugInfo = {
routes: routeInfo,
server: {
formatters: self.formatters,
// if server is not yet listening, addressInfo may be null
address: (addressInfo && addressInfo.address),
port: (addressInfo && addressInfo.port),
inflightRequests: self.inflightRequests(),
pre: self.before.map(funcNameMapper),
use: self.chain.map(funcNameMapper),
after: self.listeners('after').map(funcNameMapper)
}
};
}
return self._debugInfo;
};

@@ -47,3 +47,9 @@ {

"description": "REST framework",
"version": "5.0.0-beta-4.0",
"keywords": [
"REST",
"framework",
"express",
"DTrace"
],
"version": "5.0.0-beta-5.0",
"repository": {

@@ -66,5 +72,7 @@ "type": "git",

"bunyan": "^1.8.1",
"clone-regexp": "^1.0.0",
"csv": "^1.1.0",
"escape-regexp-component": "^1.0.2",
"formidable": "^1.0.17",
"lodash": "^4.17.4",
"lru-cache": "^4.0.1",

@@ -89,3 +97,3 @@ "mime": "^1.2.11",

"jscs": "^3.0.0",
"nodeunit": "^0.9.1",
"nodeunit": "^0.11.0",
"nsp": "^2.2.0",

@@ -92,0 +100,0 @@ "restify-clients": "^1.2.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc