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

hyperswitch

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperswitch - npm Package Compare versions

Comparing version 0.9.6 to 0.10.0

2

lib/filters/http.js

@@ -33,3 +33,3 @@ "use strict";

hyper.log('trace/webrequest', {
hyper.logger.log('trace/webrequest', {
request_id: req.headers['x-request-id'],

@@ -36,0 +36,0 @@ req,

@@ -24,3 +24,3 @@ 'use strict';

if (hyper.ratelimiter.isAboveLimit(key, options.limits[requestClass])) {
hyper.log(`warn/ratelimit/${pathKey}`, {
hyper.logger.log(`warn/ratelimit/${pathKey}`, {
key,

@@ -27,0 +27,0 @@ rate_limit_per_second: options.limits[requestClass],

@@ -40,3 +40,3 @@ 'use strict';

parOptions = parOptions || {};
this.log = parOptions.log || par.log;
this.logger = parOptions.logger || par.logger;
this.metrics = parOptions.metrics || par.metrics;

@@ -67,3 +67,3 @@ this.ratelimiter = parOptions.ratelimiter || par.ratelimiter;

// Brand new instance
this.log = options.log; // Logging method
this.logger = options.logger;
this.metrics = options.metrics;

@@ -232,3 +232,3 @@ this.ratelimiter = options.ratelimiter;

.then((res) => {
childHyperSwitch.log('trace/hyper/response', {
childHyperSwitch.logger.log('trace/hyper/response', {
req,

@@ -365,3 +365,3 @@ res,

HyperSwitch.prototype._isSysRequest = req => (req.params && req.params.api === 'sys')
// TODO: Remove once params.api is reliable
// TODO: Remove once params.api is reliable
|| (req.uri.path && req.uri.path.length > 1 && req.uri.path[1] === 'sys');

@@ -368,0 +368,0 @@

@@ -118,4 +118,4 @@ "use strict";

// Append the log property to module options, if it is not present
if (!options.log) {
options.log = this._options.log || (() => {});
if (!options.logger) {
options.logger = this._options.logger;
}

@@ -210,3 +210,3 @@ return options;

spec,
globals: { options, log: options.log },
globals: { options },
// Needed to check cache validity.

@@ -242,3 +242,2 @@ _parentGlobals: globals,

if (!mod.globals) { mod.globals = {}; }
mod.globals.log = options.log;
// Needed to check cache validity.

@@ -603,3 +602,3 @@ mod._parentGlobals = globals;

* Main request routing entry point.
* @param {URI|String} uri URI object
* @param {URI|string} uri URI object
* @return {Object} match:

@@ -606,0 +605,0 @@ * - @prop {Object} value:

@@ -109,3 +109,3 @@ "use strict";

}
opts.log(logLevel, {
opts.logger.log(logLevel, {
message: response.message || 'Request sample',

@@ -121,3 +121,3 @@ res: {

if (response.status >= 500) {
opts.log('error/request', {
opts.logger.log('error/request', {
message: response.message,

@@ -238,3 +238,3 @@ res: response,

} else {
opts.log('error/request', {
opts.logger.log('error/request', {
root_req: req,

@@ -278,3 +278,2 @@ response: response.stack || response.toString(),

conf: opts.conf,
log: null,
reqId: req.headers['x-request-id'],

@@ -308,3 +307,3 @@ metrics: opts.metrics,

// Create a child logger with selected request information.
reqOpts.logger = opts.logger && opts.logger.child({
reqOpts.logger = opts.logger.child({
root_req: {

@@ -329,3 +328,2 @@ method: req.method.toLowerCase(),

});
reqOpts.log = reqOpts.logger && reqOpts.logger.log.bind(reqOpts.logger) || (() => {});

@@ -360,3 +358,3 @@ // Create a new, clean request object

} catch (e) {
reqOpts.log('error/request/json-parsing', e);
reqOpts.logger.log('error/request/json-parsing', e);
}

@@ -394,4 +392,3 @@ }

conf,
logger: options.logger,
log: options.logger && options.logger.log.bind(options.logger) || (() => {}),
logger: options.logger || utils.nullLogger,
metrics: options.metrics,

@@ -427,3 +424,3 @@ ratelimiter: options.ratelimiter,

main.server.listen(port, host);
opts.log('warn/startup', `listening on ${host || '*'}:${port}`);
opts.logger.log('warn/startup', `listening on ${host || '*'}:${port}`);
// Don't delay incomplete packets for 40ms (Linux default) on

@@ -446,3 +443,3 @@ // pipelined HTTP sockets. We write in large chunks or buffers, so

.catch((e) => {
opts.log('fatal/startup', {
opts.logger.log('fatal/startup', {
status: e.status,

@@ -449,0 +446,0 @@ err: e,

@@ -63,2 +63,22 @@ "use strict";

/**
* In case a logger is not provided, use this class as a replacement
* to avoid TypeErrors and undefined logger instances. \
*
* Added for backwards compatibility, since not all the clients are ready to
* undefined logger instance.
*/
class NullLogger {
log() {
// no-op
}
child() {
return new NullLogger();
}
close() {
// no-op
}
}
utils.nullLogger = new NullLogger();
module.exports = utils;
{
"name": "hyperswitch",
"version": "0.9.6",
"version": "0.10.0",
"description": "REST API creation framework",

@@ -29,26 +29,26 @@ "main": "index.js",

"busboy": "^0.2.14",
"js-yaml": "^3.10.0",
"js-yaml": "^3.11.0",
"cassandra-uuid": "^0.0.2",
"preq": "^0.5.4",
"preq": "^0.5.6",
"swagger-router": "^0.7.1",
"swagger-ui": "git+https://github.com/wikimedia/swagger-ui#master",
"json-stable-stringify": "^1.0.1",
"ajv": "^5.5.0",
"ajv": "^6.4.0",
"regexp-utils": "^0.3.2"
},
"devDependencies": {
"coveralls": "^3.0.0",
"coveralls": "^3.0.1",
"istanbul": "^0.4.5",
"mocha": "^4.0.1",
"mocha": "^5.1.1",
"mocha-jshint": "^2.3.1",
"mocha-lcov-reporter": "^1.3.0",
"nock": "^9.1.3",
"service-runner": "^2.4.5",
"nock": "^9.2.5",
"service-runner": "^2.6.1",
"mocha-eslint": "^4.1.0",
"eslint": "^4.12.0",
"eslint": "^4.19.1",
"eslint-config-node-services": "^2.2.5",
"eslint-config-wikimedia": "^0.5.0",
"eslint-plugin-jsdoc": "^3.1.0",
"eslint-plugin-jsdoc": "^3.6.3",
"eslint-plugin-json": "^1.2.0"
}
}

@@ -10,4 +10,6 @@ "use strict";

var yaml = require('js-yaml');
const util = require('../../lib/utils');
var fakeHyperSwitch = { config: {} };
const ROUTER_OPTS = { appBasePath: __dirname, logger: util.nullLogger };

@@ -83,3 +85,3 @@ var noopResponseHanlder = {

it('should allow adding methods to existing paths', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec(additionalMethodSpec, fakeHyperSwitch)

@@ -94,3 +96,3 @@ .then(function() {

it('should error on overlapping methods on the same path', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec(overlappingMethodSpec, fakeHyperSwitch)

@@ -106,3 +108,3 @@ .then(function() {

it('should pass permission along the path to endpoint', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec(nestedSecuritySpec, fakeHyperSwitch)

@@ -120,3 +122,3 @@ .then(function() {

it('should fail when no handler found for method', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec(noHandlerSpec, fakeHyperSwitch)

@@ -134,3 +136,3 @@ .then(function() {

var spec = yaml.safeLoad(fs.readFileSync(__dirname + '/multi_domain_spec.yaml'));
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec(spec, fakeHyperSwitch)

@@ -144,3 +146,3 @@ .then(function() {

it('support loading modules from absolute paths', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -158,3 +160,3 @@ paths: {

it('supports merging api specs from different modules', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -185,3 +187,3 @@ paths: {

it('supports exposing top-level spec', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec(yaml.safeLoad(fs.readFileSync(__dirname + '/root_api_spec.yaml')), fakeHyperSwitch)

@@ -202,3 +204,3 @@ .then(function() {

it('supports recursive matching with + modifier', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -217,3 +219,3 @@ paths: {

it('supports optional matching', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -235,3 +237,3 @@ paths: {

it('does not explode on empty spec', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -243,3 +245,3 @@ paths: { }

it('passes options to modules', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
// The error is thrown by options_testing_module in case options are not passed correctly

@@ -269,3 +271,3 @@ return router.loadSpec({

it('calls resources when module is created', function(done) {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
router.loadSpec({

@@ -302,3 +304,3 @@ paths: {

it('finds module with in app basePath node_modules', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -321,3 +323,3 @@ paths: {

it('throws error if module is not found', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -343,3 +345,3 @@ paths: {

it('throws error on invalid modules definition', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -362,3 +364,3 @@ paths: {

it('supports multiple optional parameters', function() {
var router = new Router({ appBasePath: __dirname });
var router = new Router(ROUTER_OPTS);
return router.loadSpec({

@@ -365,0 +367,0 @@ paths: {

@@ -9,3 +9,3 @@ "use strict";

assert.deepEqual(options.templates, { sample_template: '{{should not be expanded}}' });
assert.deepEqual(typeof options.log, 'function');
assert.deepEqual(!!options.logger, true );
return {

@@ -12,0 +12,0 @@ spec: {

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