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

restify

Package Overview
Dependencies
Maintainers
0
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 0.1.12 to 0.1.13

57

lib/restify.js

@@ -23,43 +23,4 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.

// --- Globals
var _response;
var _errorHandler = null;
// --- Internal Helpers
function _installExceptionHandler(handler) {
if (handler) {
if (typeof(handler) !== 'function')
throw new TypeError('Restify exception handlers must be a function');
}
if (_errorHandler) {
process.removeAllListeners('uncaughtException');
_errorHandler = null;
}
if (handler) {
_errorHandler = handler;
} else {
_errorHandler = function(response) {
return response.sendError(newError({
httpCode: HttpCodes.InternalError,
restCode: RestCodes.UnknownError,
message: 'An internal server error occurred.'
}));
};
}
process.on('uncaughtException', function(e) {
log.warn('uncaughtException: ' + (e.stack ? e.stack : e));
if (_response) {
return _errorHandler(_response);
}
});
}
/**

@@ -386,5 +347,2 @@ * Cleans up sloppy URL paths, like /foo////bar/// to /foo/bar.

* Default: 300
* - onError: Function to set on uncaught exceptions; takes
* a single argument, 'response'.
* Default: restify f(n) that sends back 500.
* - apiVersion: Default API version to support; setting this

@@ -451,8 +409,6 @@ * means clients are required to send an

if (route.handlers[_i]) {
if (log.trace()) {
if (log.trace())
log.trace('Running handler: %s:: %d', request.method, _i);
}
return route.handlers[_i++].call(this, request, response, self);
} else {
_response = null;
}

@@ -500,3 +456,2 @@ });

}
_response = null;
}

@@ -528,7 +483,2 @@ });

if (options.onError) {
_installExceptionHandler(options.onError);
installedExceptionHandler = true;
}
if (options.maxRequestSize)

@@ -566,5 +516,2 @@ server._config.maxRequestSize = options.maxRequestSize;

if (!installedExceptionHandler)
_installExceptionHandler();
server._config._acceptable = {};

@@ -571,0 +518,0 @@ for (var i = 0; i < server._config.acceptable.length; i++) {

4

package.json
{
"name": "restify",
"description": "REST framework specifically meant for web service APIs",
"version": "0.1.12",
"version": "0.1.13",
"repository": {

@@ -16,3 +16,3 @@ "type": "git",

"pretest": "./node_modules/.bin/jshint lib tst",
"test": "./node_modules/.bin/whiskey --sequential -t \"`find tst -name *.test.js | xargs`\""
"test": "./node_modules/.bin/whiskey -t \"`find tst -name *.test.js | xargs`\""
},

@@ -19,0 +19,0 @@ "man": [

// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
var fs = require('fs');
var http = require('httpu');

@@ -103,45 +104,49 @@ var uuid = require('node-uuid');

exports.test_create_default_error_handler = function(test, assert) {
var server = restify.createServer();
var socket = '/tmp/.' + uuid();
// exports.test_create_default_error_handler = function(test, assert) {
// var server = restify.createServer();
// var socket = '/tmp/.' + uuid();
server.get('/', function(req, res, next) { throw new Error('Default me!'); });
server.listen(socket, function() {
var opts = common.newOptions(socket, '/');
http.request(opts, function(res) {
common.checkResponse(assert, res);
assert.equal(res.headers.server, 'node.js');
assert.equal(res.statusCode, 500);
server.on('close', function() {
test.finish();
});
server.close();
}).end();
});
};
// server.get('/', function(req, res, next) {
// fs.stat('/tmp', function(err, stats) {
// throw new Error('Default me!');
// });
// });
// server.listen(socket, function() {
// var opts = common.newOptions(socket, '/');
// http.request(opts, function(res) {
// common.checkResponse(assert, res);
// assert.equal(res.headers.server, 'node.js');
// assert.equal(res.statusCode, 500);
// server.on('close', function() {
// test.finish();
// });
// server.close();
// }).end();
// });
// };
exports.test_create_user_error_handler = function(test, assert) {
var server = restify.createServer({
onError: function(res) {
assert.ok(res);
res.send(503);
}
});
var socket = '/tmp/.' + uuid();
// exports.test_create_user_error_handler = function(test, assert) {
// var server = restify.createServer({
// onError: function(err, req, res) {
// assert.ok(res);
// res.send(503);
// }
// });
// var socket = '/tmp/.' + uuid();
server.get('/', function(req, res, next) { throw new Error('503 me!'); });
server.listen(socket, function() {
var opts = common.newOptions(socket, '/');
http.request(opts, function(res) {
common.checkResponse(assert, res);
assert.equal(res.headers.server, 'node.js');
assert.equal(res.statusCode, 503);
server.on('close', function() {
test.finish();
});
server.close();
}).end();
});
};
// server.get('/', function(req, res, next) { throw new Error('503 me!'); });
// server.listen(socket, function() {
// var opts = common.newOptions(socket, '/');
// http.request(opts, function(res) {
// common.checkResponse(assert, res);
// assert.equal(res.headers.server, 'node.js');
// assert.equal(res.statusCode, 503);
// server.on('close', function() {
// test.finish();
// });
// server.close();
// }).end();
// });
// };

@@ -148,0 +153,0 @@

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