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

slonik-interceptor-query-logging

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slonik-interceptor-query-logging - npm Package Compare versions

Comparing version 1.4.7 to 40.2.4

CHANGELOG.md

43

package.json

@@ -12,3 +12,3 @@ {

"files": [
"test/slonik-interceptor-query-logging/**/*"
"src/**/*.test.ts"
],

@@ -26,16 +26,6 @@ "require": [

"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"ava": "^3.15.0",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-transform-export-default-name": "^2.1.0",
"coveralls": "^3.1.1",
"del-cli": "^4.0.1",
"eslint": "^8.4.1",
"eslint-config-canonical": "^32.46.0",
"husky": "^7.0.4",
"inline-loops.macro": "^1.2.2",
"nyc": "^15.1.0",
"semantic-release": "^18.0.1",
"sinon": "^12.0.1",
"ava": "^5.3.1",
"eslint": "^8.57.0",
"eslint-config-canonical": "^42.8.1",
"slonik": "^40.2.4",
"ts-node": "^10.4.0",

@@ -45,9 +35,4 @@ "typescript": "^4.5.3"

"engines": {
"node": ">=8.0"
"node": ">=18"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint && npm run test && npm run build"
}
},
"keywords": [

@@ -59,18 +44,18 @@ "postgresql",

"license": "BSD-3-Clause",
"main": "./dist/src/index.js",
"main": "./dist/index.js",
"name": "slonik-interceptor-query-logging",
"peerDependencies": {
"slonik": ">=27.0.0"
"slonik": ">=40.2.4"
},
"repository": {
"type": "git",
"url": "https://github.com/gajus/slonik-interceptor-query-logging"
"url": "https://github.com/gajus/slonik"
},
"scripts": {
"build": "del-cli ./dist && tsc",
"lint": "eslint ./src ./test && tsc --noEmit",
"test": "NODE_ENV=test nyc ava --verbose --serial"
"build": "rm -fr ./dist && tsc",
"lint": "eslint ./src && tsc --noEmit",
"test": "ava --verbose --serial"
},
"typings": "./dist/src/index.d.ts",
"version": "1.4.7"
"typings": "./dist/index.d.ts",
"version": "40.2.4"
}
# slonik-interceptor-query-logging
[![Travis build status](http://img.shields.io/travis/gajus/slonik-interceptor-query-logging/master.svg?style=flat-square)](https://travis-ci.com/github/gajus/slonik-interceptor-query-logging)
[![Coveralls](https://img.shields.io/coveralls/gajus/slonik-interceptor-query-logging.svg?style=flat-square)](https://coveralls.io/github/gajus/slonik-interceptor-query-logging)
[![NPM version](http://img.shields.io/npm/v/slonik-interceptor-query-logging.svg?style=flat-square)](https://www.npmjs.org/package/slonik-interceptor-query-logging)

@@ -6,0 +4,0 @@ [![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)

@@ -0,12 +1,6 @@

import { getAutoExplainPayload } from '../utilities/getAutoExplainPayload';
import { isAutoExplainJsonMessage } from '../utilities/isAutoExplainJsonMessage';
import prettyMs from 'pretty-ms';
import {
serializeError,
} from 'serialize-error';
import type {
Interceptor,
} from 'slonik';
import {
getAutoExplainPayload,
isAutoExplainJsonMessage,
} from '../utilities';
import { serializeError } from 'serialize-error';
import { type Interceptor } from 'slonik';

@@ -17,7 +11,13 @@ /**

type UserConfigurationType = {
logValues: boolean,
logValues: boolean;
};
const stringifyCallSite = (callSite) => {
return (callSite.fileName || '') + ':' + callSite.lineNumber + ':' + callSite.columnNumber;
return (
(callSite.fileName || '') +
':' +
callSite.lineNumber +
':' +
callSite.columnNumber
);
};

@@ -29,3 +29,5 @@

export const createQueryLoggingInterceptor = (userConfiguration?: UserConfigurationType): Interceptor => {
export const createQueryLoggingInterceptor = (
userConfiguration?: UserConfigurationType,
): Interceptor => {
const configuration = {

@@ -50,12 +52,21 @@ ...defaultConfiguration,

if (isAutoExplainJsonMessage(notice.message)) {
context.log.info({
autoExplain: getAutoExplainPayload(notice.message),
}, 'auto explain');
context.log.info(
{
autoExplain: getAutoExplainPayload(notice.message),
},
'auto explain',
);
}
}
context.log.debug({
executionTime: prettyMs(Number(process.hrtime.bigint() - BigInt(context.queryInputTime)) / 1_000_000),
rowCount,
}, 'query execution result');
context.log.debug(
{
executionTime: prettyMs(
Number(process.hrtime.bigint() - BigInt(context.queryInputTime)) /
1_000_000,
),
rowCount,
},
'query execution result',
);

@@ -72,3 +83,7 @@ return null;

// Hide the internal call sites.
if (callSite.fileName !== null && !callSite.fileName.includes('slonik') && !callSite.fileName.includes('next_tick')) {
if (
callSite.fileName !== null &&
!callSite.fileName.includes('node_modules/slonik/') &&
!callSite.fileName.includes('next_tick')
) {
stackTrace.push(stringifyCallSite(callSite));

@@ -93,7 +108,10 @@ }

context.log.debug({
sql: query.sql,
stackTrace,
values,
}, 'executing query');
context.log.debug(
{
sql: query.sql,
stackTrace,
values,
},
'executing query',
);

@@ -103,5 +121,8 @@ return null;

queryExecutionError: (context, query, error) => {
context.log.error({
error: serializeError(error),
}, 'query execution produced an error');
context.log.error(
{
error: serializeError(error),
},
'query execution produced an error',
);

@@ -108,0 +129,0 @@ return null;

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

// @flow
export {
createQueryLoggingInterceptor,
} from './factories';
export { createQueryLoggingInterceptor } from './factories/createQueryLoggingInterceptor';

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

import {
extractJson,
} from 'crack-json';
import { extractJson } from 'crack-json';

@@ -9,3 +7,5 @@ export const getAutoExplainPayload = (noticeMessage: string) => {

if (matches.length === 0) {
throw new Error('Notice message does not contain a recognizable JSON payload.');
throw new Error(
'Notice message does not contain a recognizable JSON payload.',
);
}

@@ -12,0 +12,0 @@

export const isAutoExplainJsonMessage = (noticeMessage: string): boolean => {
return noticeMessage.trim().startsWith('duration:') && noticeMessage.includes('{');
return (
noticeMessage.trim().startsWith('duration:') && noticeMessage.includes('{')
);
};

@@ -5,4 +5,7 @@ {

"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"es2021"
],
"module": "commonjs",

@@ -12,17 +15,12 @@ "moduleResolution": "node",

"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false,
"outDir": "dist",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es2018"
"target": "es2020",
"useUnknownInCatchVariables": false
},
"exclude": [
"dist",
"node_modules"
],
"include": [
"src",
"test"
"src"
]
}
}
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