New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ganomede-base-client

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ganomede-base-client - npm Package Compare versions

Comparing version

to
1.1.0

coverage/coverage.json

2

package.json
{
"name": "ganomede-base-client",
"version": "1.0.3",
"version": "1.1.0",
"description": "Simple wrapper for restify.JsonClient",

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

@@ -6,7 +6,8 @@ # ganomede-base-client

- single `request()`-like method (`#apiCall({method, path, body, headers, qs})`), meaning:
- single `request()`-like method (`#apiCall({method, path, body, headers, qs}, callback)`), meaning:
- base urls;
- per request headers;
- easier query string;
- supports path prefixes (useful if you want to have something like `/api/v1` in front of all requests).
- supports path prefixes (useful if you want to have something like `/api/v1` in front of all requests);
- if `body` or `qs` contain `req_id` param, sets `x-request-id` header to value of it.

@@ -13,0 +14,0 @@ ## Basic Usage

@@ -34,2 +34,9 @@ 'use strict';

_extendedHeaders ({body, qs}) {
const reqId = (qs || {}).req_id || (body || {}).req_id || null;
return reqId
? {'x-request-id': reqId}
: {};
}
apiCall ({method, path, headers = {}, body = null, qs = null}, callback) {

@@ -39,9 +46,10 @@ this._checkArgs({method, path, headers, body, qs});

const formattedQs = qs ? `?${querystring.stringify(qs)}` : '';
const args = [{
const opts = {
path: this.pathPrefix + path + formattedQs,
headers
}];
headers: Object.assign(this._extendedHeaders({body, qs}), headers)
};
if (body)
args.push(body);
const args = body
? [opts, body]
: [opts];

@@ -48,0 +56,0 @@ return this.api[method](...args, (err, req, res, obj) => {