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

@serverless/sdk

Package Overview
Dependencies
Maintainers
6
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless/sdk - npm Package Compare versions

Comparing version 0.5.11 to 0.5.12

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

### [0.5.12](https://github.com/serverless/console/compare/@serverless/sdk@0.5.11...@serverless/sdk@0.5.12) (2023-04-26)
### Features
- Full resolution of paths that involve nested express routers ([e3641aa](https://github.com/serverless/console/commit/e3641aa245c2471bf1a4eae895af13674bf5d222))
### [0.5.11](https://github.com/serverless/console/compare/@serverless/sdk@0.5.10...@serverless/sdk@0.5.11) (2023-04-21)

@@ -7,0 +13,0 @@

38

lib/instrumentation/express/instrument-layer-prototype.js

@@ -21,2 +21,3 @@ 'use strict';

let expressRouteData;
let isRouterMiddleware;
try {

@@ -30,6 +31,7 @@ if (!expressSpansMap.has(req)) {

const endTime = process.hrtime.bigint();
if (expressRouteData.route && expressRouteData.route.path && rootSpan) {
const rootSpan = serverlessSdk.traceSpans.root;
if (rootSpan && expressRouteData.path) {
// Override eventual API Gateway's `resourcePath`
rootSpan.tags.delete('aws.lambda.http_router.path');
rootSpan.tags.set('aws.lambda.http_router.path', expressRouteData.route.path);
rootSpan.tags.set('aws.lambda.http_router.path', expressRouteData.path);
}

@@ -45,3 +47,3 @@ for (const subSpan of openedSpans) {

const { routeSpan, openedSpans } = expressRouteData;
const isRouterMiddleware = Boolean(!routeSpan && this.route);
isRouterMiddleware = Boolean(!routeSpan && this.route);
const middlewareSpanName = (() => {

@@ -58,19 +60,19 @@ if (routeSpan) {

}
return isRouterMiddleware
? 'express.middleware.router'
: `express.middleware.${generateMiddlewareName(this.name) || 'unknown'}`;
if (isRouterMiddleware) return 'express.middleware.router';
if (this.name === 'router' && this.path) {
return `express.middleware.router.${generateMiddlewareName(this.path) || 'unknown'}`;
}
return `express.middleware.${generateMiddlewareName(this.name) || 'unknown'}`;
})();
middlewareSpan = serverlessSdk._createTraceSpan(middlewareSpanName);
openedSpans.add(middlewareSpan);
if (
this.path &&
(!expressRouteData.path || expressRouteData.path.length < this.path.length)
) {
expressRouteData.path = this.path;
if (this.path) {
if (isRouterMiddleware) {
expressRouteData.path = (expressRouteData.nestedPath || '') + this.path;
} else {
expressRouteData.nestedPath = (expressRouteData.nestedPath || '') + this.path;
}
}
if (this.method) expressRouteData.method = this.method;
if (isRouterMiddleware) {
expressRouteData.routeSpan = middlewareSpan;
expressRouteData.route = this.route;
}
if (isRouterMiddleware) expressRouteData.routeSpan = middlewareSpan;
} catch (error) {

@@ -86,5 +88,3 @@ reportError(error);

middlewareSpan.close();
if (this.route) {
delete expressRouteData.routeSpan;
}
if (isRouterMiddleware) delete expressRouteData.routeSpan;
}

@@ -139,3 +139,1 @@ } catch (error) {

const serverlessSdk = require('../../..');
const rootSpan = serverlessSdk.traceSpans.root;
{
"name": "@serverless/sdk",
"repository": "serverless/console",
"version": "0.5.11",
"version": "0.5.12",
"author": "Serverless, Inc.",

@@ -6,0 +6,0 @@ "dependencies": {

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