🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

rest-query

Package Overview
Dependencies
Maintainers
1
Versions
676
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-query - npm Package Compare versions

Comparing version

to
0.0.12

30

lib/restQuery.js

@@ -75,3 +75,4 @@ /*

root: { value: app.createObjectNode( {} ) , enumerable: true } ,
collections: { value: {} , enumerable: true }
collections: { value: {} , enumerable: true } ,
httpOptions: { value: {} , enumerable: true }
} ) ;

@@ -101,2 +102,12 @@

// Set up the behaviour for CORS, argument can be a string or a function( OriginHeader ) that return a CORS path.
// Note that you don't have to give the full header, only the path.
// E.g.: '*' -> 'Access-Control-Allow-Origin: "*"'
restQuery.App.prototype.setAllowOrigin = function setAllowOrigin( rule )
{
this.httpOptions.allowOrigin = rule ;
} ;
restQuery.App.prototype.createCollectionNode = function createCollectionNode( name , descriptor , collectionNode )

@@ -211,3 +222,3 @@ {

{
var performer , self = this ;
var performer , headers , self = this ;

@@ -218,2 +229,17 @@ restQuery.httpParser.parseRequest( httpRequest , function( error , message ) {

headers = { 'Content-Type': 'text/html' } ;
// CORS
if ( self.httpOptions.allowOrigin )
{
if ( typeof self.httpOptions.allowOrigin === 'string' )
{
headers[ 'Access-Control-Allow-Origin' ] : '"' + self.httpOptions.allowOrigin + '"' ;
}
else if ( typeof self.httpOptions.allowOrigin === 'function' )
{
headers[ 'Access-Control-Allow-Origin' ] : '"' + self.httpOptions.allowOrigin( httpRequest.headers.origin ) + '"' ;
}
}
//# debug : console.log( string.inspect( { style: 'color' } , message ) ) ;

@@ -220,0 +246,0 @@

2

package.json
{
"name": "rest-query",
"version": "0.0.11",
"version": "0.0.12",
"description": "Perform REST queries directly on your database!",

@@ -5,0 +5,0 @@ "main": "lib/restQuery.js",

@@ -1166,2 +1166,9 @@ /*

describe( "Misc" , function() {
it( "Test CORS" ) ;
} ) ;