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

mappersmith

Package Overview
Dependencies
Maintainers
0
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mappersmith - npm Package Compare versions

Comparing version 2.44.0 to 2.45.0

6

CHANGELOG.md
# Changelog
## 2.45.0
### Minor Changes
- 624c15d: Switch to using default imports for libraries imported in gateway
## 2.44.0

@@ -4,0 +10,0 @@

2

gateway/http.d.ts
/// <reference types="node" />
import * as http from 'http';
import http from 'http';
import { Gateway } from './gateway';

@@ -4,0 +4,0 @@ import type { Method, HTTPGatewayConfiguration, HTTPRequestParams } from './types';

@@ -35,5 +35,5 @@ "use strict";

module.exports = __toCommonJS(http_exports);
var url = __toESM(require("url"));
var http = __toESM(require("http"));
var https = __toESM(require("https"));
var import_url = __toESM(require("url"));
var import_http = __toESM(require("http"));
var import_https = __toESM(require("https"));
var import_utils = require("../utils/index");

@@ -65,3 +65,3 @@ var import_gateway = require("./gateway");

const headers = {};
const defaults = url.parse(this.request.url());
const defaults = import_url.default.parse(this.request.url());
const method = this.shouldEmulateHTTP() ? "post" : requestMethod;

@@ -75,3 +75,3 @@ const body = this.prepareBody(requestMethod, headers);

}
const handler = defaults.protocol === "https:" ? https : http;
const handler = defaults.protocol === "https:" ? import_https.default : import_http.default;
const requestParams = (0, import_utils.assign)(defaults, {

@@ -78,0 +78,0 @@ method,

{
"name": "mappersmith",
"version": "2.44.0",
"version": "2.45.0",
"description": "It is a lightweight rest client for node.js and the browser",

@@ -5,0 +5,0 @@ "author": "Tulio Ornelas <ornelas.tulio@gmail.com>",

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

import * as url from 'url'
import * as http from 'http'
import * as https from 'https'
import url from 'url'
import http from 'http'
import https from 'https'

@@ -5,0 +5,0 @@ import { assign } from '../utils/index'

@@ -164,2 +164,109 @@ import forge from '../index'

})
describe('both', () => {
beforeEach(() => {
mockRequest({
method: 'post',
url: `${host}${path}`,
body: m.anything(),
headers: {},
response: {
body: { ok: true },
status: 200,
},
})
})
const createMiddleware =
(
prepareRequestSpy: jest.Mock,
responseSpy: jest.Mock,
beforeParams: Record<string, string>,
afterParams: Record<string, string>
): Middleware =>
() => ({
prepareRequest: async (next) => {
prepareRequestSpy(beforeParams)
const request = await next()
prepareRequestSpy(afterParams)
return request
},
response: async (next) => {
responseSpy(beforeParams)
const response = await next()
responseSpy(afterParams)
return response
},
})
it('invokes middleware and extends response context in given order', async () => {
const prepareRequestSpy = jest.fn()
const responseSpy = jest.fn()
const mw1 = createMiddleware(prepareRequestSpy, responseSpy, { foo: 'mw1' }, { bar: 'mw1' })
const mw2 = createMiddleware(prepareRequestSpy, responseSpy, { ctx: 'mw2' }, { fizz: 'mw2' })
const mw3 = createMiddleware(prepareRequestSpy, responseSpy, { ctx: 'mw3' }, { buzz: 'mw3' })
const client = forge({
clientId: 'testMw',
middleware: [mw1, mw2, mw3],
host,
resources: { Resource: { create: { method: 'post', path } } },
})
await client.Resource.create()
// order of prepareRequest
expect(prepareRequestSpy).toHaveBeenCalledTimes(6)
expect(prepareRequestSpy).toHaveBeenNthCalledWith(1, { ctx: 'mw3' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(2, { ctx: 'mw2' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(3, { foo: 'mw1' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(4, { bar: 'mw1' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(5, { fizz: 'mw2' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(6, { buzz: 'mw3' })
// order of response
expect(responseSpy).toHaveBeenCalledTimes(6)
expect(responseSpy).toHaveBeenNthCalledWith(1, { ctx: 'mw3' })
expect(responseSpy).toHaveBeenNthCalledWith(2, { ctx: 'mw2' })
expect(responseSpy).toHaveBeenNthCalledWith(3, { foo: 'mw1' })
expect(responseSpy).toHaveBeenNthCalledWith(4, { bar: 'mw1' })
expect(responseSpy).toHaveBeenNthCalledWith(5, { fizz: 'mw2' })
expect(responseSpy).toHaveBeenNthCalledWith(6, { buzz: 'mw3' })
})
it('invokes resource specific middleware first', async () => {
const prepareRequestSpy = jest.fn()
const responseSpy = jest.fn()
const mw1 = createMiddleware(prepareRequestSpy, responseSpy, { foo: 'mw1' }, { bar: 'mw1' })
const mw2 = createMiddleware(prepareRequestSpy, responseSpy, { ctx: 'mw2' }, { fizz: 'mw2' })
const mw3 = createMiddleware(prepareRequestSpy, responseSpy, { ctx: 'mw3' }, { buzz: 'mw3' })
const client = forge({
clientId: 'testMw',
middleware: [mw1, mw3],
host,
resources: { Resource: { post: { method: 'post', path, middleware: [mw2] } } },
})
await client.Resource.post()
// order of prepareRequest
expect(prepareRequestSpy).toHaveBeenCalledTimes(6)
expect(prepareRequestSpy).toHaveBeenNthCalledWith(1, { ctx: 'mw3' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(2, { foo: 'mw1' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(3, { ctx: 'mw2' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(4, { fizz: 'mw2' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(5, { bar: 'mw1' })
expect(prepareRequestSpy).toHaveBeenNthCalledWith(6, { buzz: 'mw3' })
// order of response
expect(responseSpy).toHaveBeenCalledTimes(6)
expect(responseSpy).toHaveBeenNthCalledWith(1, { ctx: 'mw3' })
expect(responseSpy).toHaveBeenNthCalledWith(2, { foo: 'mw1' })
expect(responseSpy).toHaveBeenNthCalledWith(3, { ctx: 'mw2' })
expect(responseSpy).toHaveBeenNthCalledWith(4, { fizz: 'mw2' })
expect(responseSpy).toHaveBeenNthCalledWith(5, { bar: 'mw1' })
expect(responseSpy).toHaveBeenNthCalledWith(6, { buzz: 'mw3' })
})
})
})

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

export const version = '2.44.0'
export const version = '2.45.0'

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

export declare const version = "2.44.0";
export declare const version = "2.45.0";

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

module.exports = __toCommonJS(version_exports);
const version = "2.44.0";
const version = "2.45.0";
// Annotate the CommonJS export names for ESM import in node:

@@ -27,0 +27,0 @@ 0 && (module.exports = {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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