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

molindo-node-logger

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

molindo-node-logger - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

19

dist/index.js

@@ -225,3 +225,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

const MASKED_HEADER_VALUE = '*****';
var createLoggerMiddleware = (({ logger })=>{
var createLoggerMiddleware = (({ logger, maxGraphQLVariablesLength = 512 })=>{
const router = new express.Router();

@@ -244,5 +244,20 @@ return router.use(bodyParser__default.default.json(), expressWinston__default.default.logger({

if (req.method === 'POST' && req.body && req.body.operationName) {
let variables = undefined;
if (maxGraphQLVariablesLength === -1) {
variables = req.body.variables;
} else if (maxGraphQLVariablesLength === 0) {
// Keep variables undefined
variables = undefined;
} else if (maxGraphQLVariablesLength > 0) {
const stringifiedVariables = JSON.stringify(req.body.variables);
const isTooLarge = stringifiedVariables.length > maxGraphQLVariablesLength;
if (isTooLarge) {
variables = `${stringifiedVariables.substring(0, maxGraphQLVariablesLength)} […] max payload length reached (${maxGraphQLVariablesLength} chars)`;
} else {
variables = req.body.variables;
}
}
meta.graphql = {
operationName: req.body.operationName,
variables: req.body.variables
variables
};

@@ -249,0 +264,0 @@ }

2

package.json
{
"name": "molindo-node-logger",
"version": "2.0.0",
"version": "3.0.0",
"description": "A node.js logger that integrates well with the Molindo infrastructure.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -42,3 +42,5 @@ # molindo-node-logger

If you're running an express server, you can register the logger middleware to log HTTP requests.
If you're running an express server, you can register the logger middleware to
log HTTP requests. GraphQL requests get automatically detected and attached as
`meta.graphql`, with properties `operationName` and the respective `variables`.

@@ -54,1 +56,10 @@ ```js

```
The size of `meta.graphql.variables` can sometimes grow too large to log
effectively. To manage this, the `createLoggerMiddleware()` function provides a configurable parameter:
`maxGraphQLVariablesLength`.
#### Configuration of `maxGraphQLVariablesLength`
* Set `maxGraphQLVariablesLength` (default: 512), to set the maximum size of the `meta.graphql.variables` payload to be logged.
* Set `maxGraphQLVariablesLength` to `0` to completely turn off logging for `meta.graphql.variables`.
* Set `maxGraphQLVariablesLength` to `-1` to include the complete `meta.graphql.variables` payload without size restrictions.

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