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

restify

Package Overview
Dependencies
Maintainers
1
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 1.1.0 to 1.1.1

9

CHANGES.md
# restify Changelog
## 1.1.1 (not yet released)
## 1.1.1
- dependency version bumps
- res.header accepts sprintf-style arguments
- GH-95 Make restify compatible with node-logging (Andrew Robinson)
- GH-93 Minimal port of express pre-conditions (Dominic Barnes)
- GH-92 Make X-Response-Time configurable (Shaun Berryman)
- GH-87 server.listen on port as string (Andrew Sliwinski)
## 1.1.0

@@ -6,0 +13,0 @@

@@ -18,2 +18,4 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved.

var sprintf = util.format;
var HttpError = errors.HttpError;

@@ -34,4 +36,3 @@ var RestError = errors.RestError;

'X-Api-Version',
'X-Request-Id',
'X-Response-Time'
'X-Request-Id'
].join(', ');

@@ -216,3 +217,12 @@

this.version = options.version || false;
this.responseTimeHeader = options.responseTimeHeader || 'X-Response-Time';
this.responseTimeFormatter = function (duration) {
return duration;
};
// make sure the options is a function (if not we don't allow you to override)
if (typeof (options.responseTimeFormatter) === 'function') {
this.responseTimeFormatter = options.responseTimeFormatter;
}
// Generate the formatters

@@ -328,2 +338,5 @@ if (options.formatters) {

this.res.on('finish', function (src) {
return self.emit('finish', src);
});
// Finally write the default headers in

@@ -385,2 +398,6 @@ this.defaultHeaders();

// Support res.header('foo', 'bar %s', 'baz');
if (arguments.length > 2)
value = sprintf(value, Array.prototype.slice.call(arguments).slice(2));
this.setHeader(name, value);

@@ -444,3 +461,4 @@ return value;

this.header('Access-Control-Expose-Headers', EXPOSE_HEADERS);
this.header('Access-Control-Expose-Headers',
EXPOSE_HEADERS + ', ' + this.responseTimeHeader);
this.header('Server', this.serverName);

@@ -486,4 +504,6 @@

if (!this.header('X-Response-Time'))
this.header('X-Response-Time', now.getTime() - this.req.time.getTime());
if (!this.header(this.responseTimeHeader))
this.header(this.responseTimeHeader,
this.responseTimeFormatter(now.getTime() -
this.req.time.getTime()));
};

@@ -547,3 +567,2 @@

Response.prototype.format = function format(body) {

@@ -550,0 +569,0 @@ var log = this.log;

@@ -125,2 +125,4 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved.

this.version = options.version || false;
this.responseTimeHeader = options.responseTimeHeader || 'X-Response-Time';
this.responseTimeFormatter = options.responseTimeFormatter;

@@ -198,2 +200,6 @@ var secure = false;

});
this.__defineGetter__('responseTimeHeader', function () {
return options.responseTimeHeader || 'X-Response-Time';
});
}

@@ -245,2 +251,5 @@ util.inherits(Server, EventEmitter);

if (!isNaN(arguments[0]))
arguments[0] = Number(arguments[0]);
switch (typeof (arguments[0])) {

@@ -438,3 +447,5 @@ case 'function':

formatters: self.formatters,
serverName: self.name
serverName: self.name,
responseTimeHeader: self.responseTimeHeader,
responseTimeFormatter: self.responseTimeFormatter
});

@@ -532,1 +543,28 @@

};
/**
* Minimal port of the functionality offered by Express.js Route Param
* Pre-conditions
* @link http://expressjs.com/guide.html#route-param%20pre-conditions
*
* This basically piggy-backs on the `server.use` method. It attaches a
* new middleware function that only fires if the specified parameter exists
* in req.params
*
* Exposes an API:
* server.param("user", function (req, res, next) {
* // load the user's information here, always making sure to call next()
* });
*
* @param {String} The name of the URL param to respond to
* @param {Function} The middleware function to execute
*/
Server.prototype.param = function param(name, fn) {
return this.use(function (req, res, next) {
if (req.params && req.params[name])
return fn.apply(this, arguments);
return next();
});
};

20

package.json
{
"author": "Mark Cavage <mcavage@gmail.com>",
"contributors": [
"Pedro Palazón",
"Dominic Barnes",
"Shaun Berryman",
"Ben Howes",
"Trent Mick",
"Falco Nogatz",
"Pedro Palazón",
"Andrew Robinson",
"Isaac Schlueter",
"Andrew Sliwinski",
"Matt Smillie",

@@ -16,3 +20,3 @@ "Diego Torres",

"description": "REST framework",
"version": "1.1.0",
"version": "1.1.1",
"repository": {

@@ -31,16 +35,16 @@ "type": "git",

"dependencies": {
"async": "0.1.16",
"async": "0.1.18",
"bunyan": "0.6.8",
"formidable": "1.0.8",
"formidable": "1.0.9",
"dtrace-provider": "0.0.6",
"http-signature": "0.9.8",
"lru-cache": "1.0.5",
"mime": "1.2.4",
"mime": "1.2.5",
"node-uuid": "1.3.3",
"retry": "0.5.0",
"retry": "0.6.0",
"semver": "1.0.13"
},
"devDependencies": {
"filed": "0.0.5",
"tap": "0.2.2"
"filed": "0.0.6",
"tap": "0.2.3"
},

@@ -47,0 +51,0 @@ "scripts": {

@@ -110,2 +110,15 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved.

test('header (set sprintf)', function (t) {
var res = getResponse();
res.header('foo', '%s', 'bar');
res.set({
'bar': ['baz', 'bebop']
});
t.equal(res.header('foo'), 'bar');
t.equivalent(res.get('bar'), ['baz', 'bebop']);
t.end();
});
test('send plain string no code', function (t) {

@@ -112,0 +125,0 @@ var res = getResponse();

@@ -27,4 +27,2 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved.

///--- Tests

@@ -89,2 +87,12 @@

test('listen and close (port only) w/ port number as string', function (t) {
var server = new Server({ dtrace: DTRACE, log: LOGGER });
server.listen(String(PORT), function () {
server.close(function () {
t.end();
});
});
});
test('listen and close (port and hostname)', function (t) {

@@ -91,0 +99,0 @@ var server = new Server({ dtrace: DTRACE, log: LOGGER });

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