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

koatty_trace

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koatty_trace - npm Package Compare versions

Comparing version 1.3.3 to 1.3.5

yarn-error.log

5

dist/index.d.ts

@@ -5,4 +5,3 @@ /// <reference types="node" />

import { Namespace } from "cls-hooked";
import { Koatty, KoattyContext } from "koatty_core";
export * from "./Exception";
import { Koatty, KoattyContext, KoattyGrpcContext } from "koatty_core";
/**

@@ -31,2 +30,2 @@ * Create Namespace

*/
export declare function TraceHandler(app: Koatty): (ctx: KoattyContext, next: Function) => Promise<any>;
export declare function TraceHandler(app: Koatty): ((ctx: KoattyGrpcContext, callback: Function) => Promise<void>) | ((ctx: KoattyContext, next: Function) => Promise<any>);

40

dist/index.js

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

const koatty_logger_1 = require("koatty_logger");
const Exception_1 = require("./Exception");
const koatty_exception_1 = require("koatty_exception");
const uuid_1 = require("uuid");
// export
tslib_1.__exportStar(require("./Exception"), exports);
/**

@@ -75,8 +73,10 @@ * Create Namespace

// set ctx start time
Helper.define(ctx, 'startTime', Date.now());
if (ctx.call && ctx.call.handler) {
const cmd = ctx.call.handler.path || '/';
const startTime = Date.now();
ctx.setMetaData("startTime", `${startTime}`);
if (ctx.call && Object.hasOwnProperty.call(ctx.call, "handler")) {
const handler = Reflect.get(ctx.call, "handler") || {};
const cmd = handler.path || '';
// originalPath
Helper.define(ctx, 'path', cmd);
Helper.define(ctx, 'originalPath', cmd);
ctx.setMetaData("path", cmd);
ctx.setMetaData("originalPath", cmd);
}

@@ -87,4 +87,4 @@ // if enable full stack debug & trace,created traceId

// some key
const traceId = ctx.getMetaData("traceId") || ctx.request.traceId;
const requestId = ctx.getMetaData("requestId") || ctx.request.requestId;
const traceId = `${ctx.getMetaData("traceId")}` || ctx.request.traceId;
const requestId = `${ctx.getMetaData("requestId")}` || ctx.request.requestId;
// traceId

@@ -99,12 +99,12 @@ const parentId = traceId || requestId;

}
ctx.on("end", () => {
ctx.call.on("end", () => {
const now = Date.now();
const { startTime, status, originalPath } = ctx;
const msg = `{"code":"${status}","startTime":"${startTime}","duration":"${(now - startTime) || 0}","traceId":"${currTraceId}","endTime":"${now}","path":"${originalPath}"}`;
const originalPath = ctx.getMetaData("originalPath");
const startTime = ctx.getMetaData("startTime");
const msg = `{"code":"${ctx.status}","startTime":"${startTime}","duration":"${(now - Helper.toInt(startTime)) || 0}","traceId":"${currTraceId}","endTime":"${now}","path":"${originalPath}"}`;
koatty_logger_1.DefaultLogger[(ctx.status >= 1 ? 'Error' : 'Info')](msg);
ctx.end();
ctx = null;
});
// try /catch
const response = ctx.res;
const response = {};
try {

@@ -114,3 +114,3 @@ response.timeout = null;

const res = await Promise.race([new Promise((resolve, reject) => {
response.timeout = setTimeout(reject, timeout, new Exception_1.Exception('Deadline exceeded', 1, 4));
response.timeout = setTimeout(reject, timeout, new koatty_exception_1.Exception('Deadline exceeded', 1, 4));
return;

@@ -122,3 +122,3 @@ }), callback()]);

// skip prevent errors
if (Exception_1.isPrevent(err)) {
if (koatty_exception_1.isPrevent(err)) {
return null;

@@ -186,3 +186,3 @@ }

const res = await Promise.race([new Promise((resolve, reject) => {
response.timeout = setTimeout(reject, timeout, new Exception_1.Exception('Request Timeout', 1, 408));
response.timeout = setTimeout(reject, timeout, new koatty_exception_1.Exception('Request Timeout', 1, 408));
return;

@@ -197,3 +197,3 @@ }), next()]);

// skip prevent errors
if (Exception_1.isPrevent(err)) {
if (koatty_exception_1.isPrevent(err)) {
return null;

@@ -223,3 +223,3 @@ }

ctx.status = ctx.status || 500;
if (Exception_1.isException(err)) {
if (koatty_exception_1.isException(err)) {
err.message = body;

@@ -226,0 +226,0 @@ ctx.status = err.status;

{
"name": "koatty_trace",
"version": "1.3.3",
"version": "1.3.5",
"description": "Full link tracking and error interception for koatty.",

@@ -10,3 +10,3 @@ "scripts": {

"release": "standard-version",
"test": "npm run eslint && npm run build && jest --passWithNoTests",
"test": "npm run eslint && jest --passWithNoTests",
"test:cov": "jest --collectCoverage --detectOpenHandles",

@@ -52,2 +52,3 @@ "version": "conventional-changelog -p angular -i CHANGELOG.md -s"

"@commitlint/config-conventional": "^12.x.x",
"@grpc/grpc-js": "^1.x.x",
"@types/cls-hooked": "^4.x.x",

@@ -66,4 +67,2 @@ "@types/koa": "^2.x.x",

"jest-html-reporters": "^2.x.x",
"koatty_cacheable": "^1.x.x",
"koatty_schedule": "^1.x.x",
"standard-version": "^9.x.x",

@@ -78,2 +77,3 @@ "ts-jest": "^27.x.x",

"koatty_core": "^1.x.x",
"koatty_exception": "^1.x.x",
"koatty_lib": "^1.x.x",

@@ -80,0 +80,0 @@ "uuid": "^8.3.2"

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