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

volos-connectors-common

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volos-connectors-common - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

lib/lib.iml

89

lib/serverBase.js

@@ -8,2 +8,3 @@ var http = require('http');

this.init = false;
this.doParseBody = true;
this.regExpForRestMap = [];

@@ -50,3 +51,3 @@ }

function (err) {
handleError(req, resp, err, 400, '"setup" failed');
self.handleError(req, resp, err, 400, '"setup" failed');
}

@@ -167,2 +168,13 @@ );

first = true;
for (var qp in item.optionalQueryParameters) {
if (first) {
commandline += ' Optioanl Query Parameters: ';
first = false;
} else {
commandline += ', ';
}
commandline += this.getTemplateName(item.optionalQueryParameters[qp]);
}
first = true;
for (var fv in item.formVars) {

@@ -215,4 +227,7 @@ if (first) {

// use express-compatible names
req._parsedUrl = url.parse(req.url, true);
req.query = req._parsedUrl.query;
var parsedUrl = url.parse(req.url, true);
if (!req._parsedUrl) {
req._parsedUrl = parsedUrl;
}
req.query = parsedUrl.query;
req.params = {};

@@ -294,2 +309,3 @@

app.get('/' + key, function (key, req, resp) {
req._parsedUrl.key = key;
self.dispatchRequestExpress(key, queryToRestMap, req, resp);

@@ -447,2 +463,3 @@ }.bind(null, key));

if (restMap[key] != undefined) {
stuff.found = true;
stuff.queryInfo = restMap[key];

@@ -470,9 +487,14 @@ switch (req.method) {

stuff.postedBody = body;
try {
var method = eval('self.' + req._parsedUrl.key);
stuff.executeMethod = method ? method : this.unknownPath;
} catch (e) {
stuff.executeMethod = this.unknownPath;
var ok = self.doParseBody ? self.parseBody(req, body) : true;
if (ok) {
try {
var method = eval('self.' + req._parsedUrl.key);
stuff.executeMethod = method ? method : this.unknownPath;
} catch (e) {
stuff.executeMethod = this.unknownPath;
}
dfd.resolve(stuff);
} else {
dfd.reject({errorCode: 415, errorMessage: "Unsupported Media Type"});
}
dfd.resolve(stuff);
});

@@ -482,2 +504,3 @@

case 'DELETE':
found = true;
try {

@@ -492,16 +515,37 @@ var method = eval('this.' + req._parsedUrl.key);

}
if (!found) {
var response = {
errorCode: 404,
errorMessage: "Not Found"
};
stuff.response = response;
dfd.reject();
}
}
if (!found) {
var response = {
errorCode: 404,
errorMessage: "Not Found"
};
stuff.response = response;
dfd.reject();
}
return(dfd.promise);
}
ServerBase.prototype.unknownPath = function (req, resp, sqs, queryInfo) {
ServerBase.prototype.parseBody = function(req, body) {
var ok = false;
switch(req.headers['content-type']) {
case 'application/x-www-form-urlencoded':
req.body = this.parseFormvars(body);
ok = true;
break
case 'application/json':
try {
req.body = JSON.parse(body);
ok = true;
} catch (e) {
var x = 5;
}
break
case 'application/xml':
// TODO
break;
}
return(ok);
}
ServerBase.prototype.unknownPath = function (req, resp) {
var error = {

@@ -544,5 +588,4 @@ errorCode: 404,

"action" : req.method,
"params" : {
"qp" : req.query
},
"query" : req.query,
"body" : req.body,
"path" : req._parsedUrl.pathname,

@@ -563,2 +606,2 @@ "url" : req.url,

exports.ServerBase = ServerBase;
exports.ServerBase = ServerBase;

@@ -14,52 +14,2 @@ var serverBase = require('./serverBase');

SqlServerBase.prototype.prepareRequest = function(req, resp) {
var dfd = Q.defer();
var stuff = {};
var found = false;
console.log('\nRequest: ' + req.method + ' ' + req.url);
switch (req.method) {
case 'GET':
case 'DELETE':
found = true;
if (this.restMap[req._parsedUrl.key] != undefined) {
stuff.found = true;
var queryInfo = this.restMap[req._parsedUrl.key];
stuff.queryInfo = queryInfo;
}
dfd.resolve(stuff);
break;
case 'POST':
case 'PUT':
found = true;
var self = this;
var body = '';
req.on('data', function (data) {
body += data;
});
req.on('end', function () {
stuff.found = true;
stuff.postedBody = body;
var queryInfo = self.restMap[req._parsedUrl.key];
stuff.queryInfo = queryInfo;
dfd.resolve(stuff);
});
}
if (!found) {
var response = {
errorCode: 404,
errorMessage: "Not Found"
};
stuff.response = response;
dfd.reject();
}
return(dfd.promise);
}
SqlServerBase.prototype.buildQuery = function(req, resp, setupResult) {

@@ -110,8 +60,6 @@ switch(req.method) {

var command = 'INSERT INTO ' + queryInfo.table + ' (';
var body = setupResult.requestInfo.postedBody;
var formVars = this.parseFormvars(body);
// names -->
var first = true;
for (var item in formVars) {
for (var item in req.body) {
if (first) {

@@ -129,3 +77,3 @@ first = false;

first = true;
for (var item in formVars) {
for (var item in req.body) {
if (first) {

@@ -136,3 +84,10 @@ first = false;

}
command += formVars[item];
var value = req.body[item];
if (typeof value === 'string') {
command += '"';
}
command += req.body[item];
if (typeof value === 'string') {
command += '"';
}
}

@@ -154,7 +109,5 @@ // <-- values

var command = 'UPDATE ' + queryInfo.table + ' SET ';
var body = setupResult.requestInfo.postedBody;
var formVars = this.parseFormvars(body);
var first = true;
for (var item in formVars) {
for (var item in req.body) {
if (first) {

@@ -165,3 +118,11 @@ first = false;

}
command += (item + '="' + formVars[item]) + '"';
var value = req.body[item];
command += (item + '=');
if (typeof value === 'string') {
command += '"';
}
command += value;
if (typeof value === 'string') {
command += '"';
}
}

@@ -168,0 +129,0 @@ command = this.addWhereClause(req, queryInfo, command);

{
"name": "volos-connectors-common",
"version": "0.0.4",
"version": "0.0.5",
"description": "Basic support library for Volos Connectors.",

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

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