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

connect-rest

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-rest - npm Package Compare versions

Comparing version 0.0.18 to 0.0.19

28

lib/connect-rest.js

@@ -6,3 +6,3 @@ /*

*/
var VERSION = '0.0.18';
var VERSION = '0.0.19';

@@ -101,3 +101,4 @@ var connect = require('connect');

var callChain = _.map( matching, function(func){
return async.apply( func, {headers: req.headers, parameters: req.query}, bodyObj );
var headers = req.headers; headers.httpVersion=req.httpVersion; headers.method=req.method; headers.originalUrl=req.originalUrl;
return async.apply( func, {headers: headers, parameters: req.query}, bodyObj );
} );

@@ -143,2 +144,23 @@

};
exports.assign = function headRest(methods, path, functionRef, prototypeObject, options){
if( _.isString(methods) && methods == '*' ){
exports.rest( ['head','get','post','put','delete'], path, functionRef, prototypeObject, options );
} else if( _.isArray(methods) ){
_.each( methods, function(element, index, list){
if( element == 'head' )
addPath("HEAD", path, functionRef, null, options || {} );
else if( element == 'get' )
addPath("GET", path, functionRef, null, options || {} );
else if( element == 'post' )
addPath("POST", path, functionRef, prototypeObject, options || {} );
else if( element == 'put' )
addPath("PUT", path, functionRef, prototypeObject, options || {} );
else if( element == 'delete' )
addPath("DELETE", path, functionRef, prototypeObject, options || {} );
else logger.error('Not known rest type:', element);
} );
}
else
logger.error('Not correct given methods', methods);
};

@@ -198,3 +220,3 @@ exports.publish = function (services){

logger.info('Incoming request.', req.headers, req.query );
logger.info('Incoming request.', req.headers, req.query, req.httpVersion, req.method, req.originalUrl );

@@ -201,0 +223,0 @@ if( API_KEYS && API_KEYS.indexOf(req.query.api_key)==-1 ){

6

package.json
{
"name": "connect-rest",
"version": "0.0.18",
"version": "0.0.19",
"description": "RESTful web services middleware for Connect.",

@@ -49,4 +49,4 @@ "keywords": [

"readme": "README.md",
"_id": "connect-rest@0.0.18",
"_from": "connect-rest@>=0.0.18"
"_id": "connect-rest@0.0.19",
"_from": "connect-rest@>=0.0.19"
}

@@ -365,2 +365,4 @@ [connect-rest](https://github.com/imrefazekas/connect-rest) is a middleware for [connect](http://www.senchalabs.org/connect/) for building REST APIs providing service discovery and path-based parameter mapping and "reflective" publishing and node domains as well.

- 0.0.19: assign function introduced for bulk http-method assignments for a given rest function
- 0.0.18: fixes
- 0.0.16:

@@ -367,0 +369,0 @@ - better optional parameter handling allowing to use optional parameter chain like: /set/?depoartment/?room

@@ -135,2 +135,10 @@ var opt = {

function testCall9(http, _, callback){
var voptions = _.clone( opt );
voptions.method = 'GET';
voptions.path = '/api/data/items?ids%5B%5D=8&ids%5B%5D=9&api_key=849b7648-14b8-4154-9ef2-8d1dc4c2b7e9';
generalCall( http, voptions, callback );
}
exports.testCall1 = testCall1;

@@ -148,1 +156,2 @@ exports.testCall2 = testCall2;

exports.testCall8c = testCall8c;
exports.testCall9 = testCall9;

@@ -36,4 +36,10 @@ function buildUpRestAPI( rest, _ ){

}, {'title': 'Alice in Wonderland'} );
rest.get( '/data/items', function( request, content, callback ){
console.log( 'Received::' + JSON.stringify( request ) + ' ' + JSON.stringify(content) );
return callback(null, 'ok');
}, { contentType:'text/plain', validator: function(req, res){ return true; } } );
}
exports.buildUpRestAPI = buildUpRestAPI;

@@ -48,4 +48,4 @@ var rest = require('../lib/connect-rest');

protoPath: 'proto',
logger: 'connect-rest'
,domain: restDomain
logger: 'connect-rest',
domain: restDomain
};

@@ -69,5 +69,6 @@ connectApp.use( rest.rester( options ) );

// async.apply( caller.testCall7, http, _ ),
async.apply( caller.testCall8a, http, _ ),
async.apply( caller.testCall8b, http, _ ),
async.apply( caller.testCall8c, http, _ )
//async.apply( caller.testCall8a, http, _ ),
//async.apply( caller.testCall8b, http, _ ),
//async.apply( caller.testCall8c, http, _ ),
async.apply( caller.testCall9, http, _ )
], function(err, results){

@@ -74,0 +75,0 @@ console.log('Tests finished.');

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