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

jimpex

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jimpex - npm Package Compare versions

Comparing version 4.0.2 to 4.0.3

2

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://homer0.github.io/jimpex/",
"version": "4.0.2",
"version": "4.0.3",
"repository": "homer0/jimpex",

@@ -8,0 +8,0 @@ "author": "Leonardo Apiwan (@homer0) <me@homer0.com>",

@@ -18,3 +18,8 @@ const ObjectUtils = require('wootils/shared/objectUtils');

* mount.
* @property {string} path The path the route will have.
* @property {string} path The path to the endpoint relative to
* the entry point.
* @property {string} route The path the route will have. This is
* different from `path` as it's possible
* for the gateway to be implemented using
* the `root` option.
* @property {Array<GatewayControllerRouteMethod>} methods A list with all the methods the

@@ -388,3 +393,3 @@ * controller will use to mount the route.

info.method,
route.path,
route.route,
this._getMiddleware(info.endpoint),

@@ -490,2 +495,5 @@ middlewares

_createEndpointRoutes() {
const routePrefixes = this._options.root ?
`/${this._options.root}/` :
'/';
const routes = {};

@@ -526,12 +534,16 @@ Object.keys(this._endpoints).forEach((name) => {

return Object.keys(routes)
.map((endpointPath) => ({
path: routes[endpointPath].path,
methods: Object.keys(routes[endpointPath].methods).map((methodName) => ({
method: methodName,
endpoint: {
name: routes[endpointPath].methods[methodName],
settings: this._endpoints[routes[endpointPath].methods[methodName]],
},
})),
}));
.map((endpointPath) => {
const info = routes[endpointPath];
return {
path: info.path,
route: `${routePrefixes}${info.path}`,
methods: Object.keys(info.methods).map((methodName) => ({
method: methodName,
endpoint: {
name: info.methods[methodName],
settings: this._endpoints[info.methods[methodName]],
},
})),
};
});
}

@@ -538,0 +550,0 @@ /**

@@ -181,3 +181,3 @@ jest.unmock('/src/utils/functions');

expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne.substr(1), [
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne, [
expect.any(Function),

@@ -187,3 +187,3 @@ ]);

expect(router.post).toHaveBeenCalledWith(
gatewayConfig.gateway.endpointTwo.path.substr(1),
gatewayConfig.gateway.endpointTwo.path,
[expect.any(Function)]

@@ -193,2 +193,39 @@ );

it('should add the gateway routes to the router with a custom root', () => {
// Given
const gatewayConfig = {
url: 'http://my-api.com',
gateway: {
endpointOne: '/my-path/one',
endpointTwo: {
path: '/my-path/two',
method: 'post',
},
},
};
const route = '/my-gateway';
const http = 'http';
const root = 'my-root';
const options = { root };
const router = {
all: jest.fn(),
post: jest.fn(),
};
let sut = null;
// When
sut = new GatewayController(gatewayConfig, route, http, options);
sut.addRoutes(router);
// Then
expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(
`/${root}${gatewayConfig.gateway.endpointOne}`,
[expect.any(Function)]
);
expect(router.post).toHaveBeenCalledTimes(1);
expect(router.post).toHaveBeenCalledWith(
`/${root}${gatewayConfig.gateway.endpointTwo.path}`,
[expect.any(Function)]
);
});
it('should add the gateway routes to the router with a custom middleware', () => {

@@ -219,3 +256,3 @@ // Given

expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne.substr(1), [
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne, [
middleware,

@@ -226,3 +263,3 @@ expect.any(Function),

expect(router.post).toHaveBeenCalledWith(
gatewayConfig.gateway.endpointTwo.path.substr(1),
gatewayConfig.gateway.endpointTwo.path,
[

@@ -258,3 +295,3 @@ middleware,

expect(router.all).toHaveBeenCalledWith(
gatewayConfig.gateway.endpointOne.path.substr(1),
gatewayConfig.gateway.endpointOne.path,
[expect.any(Function)]

@@ -1040,3 +1077,3 @@ );

expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne.substr(1), [
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne, [
expect.any(Function),

@@ -1098,3 +1135,3 @@ ]);

expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne.substr(1), [
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne, [
expect.any(Function),

@@ -1158,3 +1195,3 @@ ]);

expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne.substr(1), [
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne, [
expect.any(Function),

@@ -1218,3 +1255,3 @@ ]);

expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne.substr(1), [
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne, [
expect.any(Function),

@@ -1277,3 +1314,3 @@ ]);

expect(router.all).toHaveBeenCalledTimes(1);
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne.substr(1), [
expect(router.all).toHaveBeenCalledWith(gatewayConfig.gateway.endpointOne, [
normalMiddleware,

@@ -1280,0 +1317,0 @@ jimpexMiddlewareName,

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