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

@smarterservices/sql-proxy-client

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smarterservices/sql-proxy-client - npm Package Compare versions

Comparing version 1.0.2 to 1.1.1

144

index.js
/*jshint -W069 */
/**
* Takes MSSQL queries and forwards them to the backend SQL server.
* @class proxy
*
* @class Client
* @param {(string|object)} [domainOrOptions] - The project domain or options object. If object, see the object's optional properties.

@@ -9,3 +9,3 @@ * @param {string} [domainOrOptions.domain] - The project domain

*/
var proxy = (function() {
var Client = (function() {
'use strict';

@@ -16,5 +16,5 @@

function proxy(options) {
function Client(options) {
var domain = (typeof options === 'object') ? options.domain : options;
this.domain = domain ? domain : '';
this.domain = domain ? domain : 'http://localhost:8000/';
if (this.domain.length === 0) {

@@ -26,11 +26,8 @@ throw new Error('Domain parameter must be specified as a string.');

/**
* endpoint to send sql query for results
*
* @method
* @name proxy#v1SelectPost
* @param {string} connection - This is to hook up with the config for that database/connection
* @param {string} database - Database to hit.
* @param {string} query - This is the query that you will send in
* @name Client#health
*
*/
proxy.prototype.v1SelectPost = function(parameters) {
Client.prototype.health = function(parameters) {
if (parameters === undefined) {

@@ -42,3 +39,3 @@ parameters = {};

var domain = this.domain;
var path = '/v1/select';
var path = '/v1';

@@ -50,29 +47,2 @@ var body;

if (parameters['connection'] !== undefined) {
form['connection'] = parameters['connection'];
}
if (parameters['connection'] === undefined) {
deferred.reject(new Error('Missing required parameter: connection'));
return deferred.promise;
}
if (parameters['database'] !== undefined) {
form['database'] = parameters['database'];
}
if (parameters['database'] === undefined) {
deferred.reject(new Error('Missing required parameter: database'));
return deferred.promise;
}
if (parameters['query'] !== undefined) {
form['query'] = parameters['query'];
}
if (parameters['query'] === undefined) {
deferred.reject(new Error('Missing required parameter: query'));
return deferred.promise;
}
if (parameters.$queryParameters) {

@@ -87,3 +57,3 @@ Object.keys(parameters.$queryParameters)

var req = {
method: 'POST',
method: 'GET',
uri: domain + path,

@@ -111,4 +81,8 @@ qs: queryParameters,

}
if (response.statusCode >= 200 && response.statusCode <= 299) {
if (response.statusCode === 204) {
deferred.resolve({
response: response
});
} else if (response.statusCode >= 200 && response.statusCode <= 299) {
deferred.resolve({
response: response,

@@ -129,13 +103,9 @@ body: body

/**
* execute stored procedures through proxy
* This route is used to proxy a stored proc
* @method
* @name proxy#v1ExecPost
* @param {string} connection - This is to hook up with the config for that database/connection
* @param {string} database - Database to hit.
* @param {string} procedure - This is the procedure you want to run
* @param {string} input - value of the input needed for the stored procedure
* @param {string} input_title - title of the input needed for the stored procedure
* @name Client#spProxy
* @param {} body -
*
*/
proxy.prototype.v1ExecPost = function(parameters) {
Client.prototype.spProxy = function(parameters) {
if (parameters === undefined) {

@@ -154,47 +124,6 @@ parameters = {};

if (parameters['connection'] !== undefined) {
form['connection'] = parameters['connection'];
if (parameters['body'] !== undefined) {
body = parameters['body'];
}
if (parameters['connection'] === undefined) {
deferred.reject(new Error('Missing required parameter: connection'));
return deferred.promise;
}
if (parameters['database'] !== undefined) {
form['database'] = parameters['database'];
}
if (parameters['database'] === undefined) {
deferred.reject(new Error('Missing required parameter: database'));
return deferred.promise;
}
if (parameters['procedure'] !== undefined) {
form['procedure'] = parameters['procedure'];
}
if (parameters['procedure'] === undefined) {
deferred.reject(new Error('Missing required parameter: procedure'));
return deferred.promise;
}
if (parameters['input'] !== undefined) {
form['input'] = parameters['input'];
}
if (parameters['input'] === undefined) {
deferred.reject(new Error('Missing required parameter: input'));
return deferred.promise;
}
if (parameters['input_title'] !== undefined) {
form['input_title'] = parameters['input_title'];
}
if (parameters['input_title'] === undefined) {
deferred.reject(new Error('Missing required parameter: input_title'));
return deferred.promise;
}
if (parameters.$queryParameters) {

@@ -232,4 +161,8 @@ Object.keys(parameters.$queryParameters)

}
if (response.statusCode >= 200 && response.statusCode <= 299) {
if (response.statusCode === 204) {
deferred.resolve({
response: response
});
} else if (response.statusCode >= 200 && response.statusCode <= 299) {
deferred.resolve({
response: response,

@@ -250,8 +183,9 @@ body: body

/**
* System health check
* This route is used for proxy of a sql request
* @method
* @name proxy#rootGet
* @name Client#sqlProxy
* @param {} body -
*
*/
proxy.prototype.rootGet = function(parameters) {
Client.prototype.sqlProxy = function(parameters) {
if (parameters === undefined) {

@@ -263,3 +197,3 @@ parameters = {};

var domain = this.domain;
var path = '/';
var path = '/v1/select';

@@ -271,2 +205,6 @@ var body;

if (parameters['body'] !== undefined) {
body = parameters['body'];
}
if (parameters.$queryParameters) {

@@ -281,3 +219,3 @@ Object.keys(parameters.$queryParameters)

var req = {
method: 'GET',
method: 'POST',
uri: domain + path,

@@ -305,4 +243,8 @@ qs: queryParameters,

}
if (response.statusCode >= 200 && response.statusCode <= 299) {
if (response.statusCode === 204) {
deferred.resolve({
response: response
});
} else if (response.statusCode >= 200 && response.statusCode <= 299) {
deferred.resolve({
response: response,

@@ -323,5 +265,5 @@ body: body

return proxy;
return Client;
})();
exports.proxy = proxy;
exports.Client = Client;

@@ -1,15 +0,1 @@

{
"name": "@smarterservices/sql-proxy-client",
"version": "1.0.2",
"description": "Client code to access and use sql proxy",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jordan Piepkow",
"license": "ISC",
"dependencies": {
"q": "^1.4.1",
"request": "^2.65.0"
}
}
{"name":"@smarterservices/sql-proxy-client","version":"1.1.1","description":"Used to proxy sql requests","main":"index.js","dependencies":{"q":"latest","request":"latest"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":"jpiepkow","license":"MIT"}

@@ -1,23 +0,4 @@

SQL Proxy Client:
sqlproxy
====
Starting:
---------
npm install sql-proxy-client
Usage example:
----------------
var api = require('sql-proxy-client');
var client = new api.proxy('http://localhost:8000'); //only option is the url and port that is hosting where you are connection to.
client.v1SelectPost({ENDPOINT REQUIRED PARAMS'})
.then(function(result) {
console.log(result);
})
**The library impliments promised based returns and should be used that way.
Docs located [Here](http://docs.sqlproxy.apiary.io/#)
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