{"id":18569,"library":"monk-middleware-debug","title":"monk-middleware-debug","description":"A debug middleware for monk versions >=5.0.0. It logs MongoDB operations to the console using the debug module. Current stable version is 0.2.0, but note that it is part of the monk ecosystem and has been superseded by monk's built-in debugging capabilities. It requires monk >=5.0.0 and mongodb driver. Release cadence is low; no active development. Key differentiator: lightweight, specifically for monk.","status":"deprecated","version":"0.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/Automattic/monk","tags":["javascript","monk","middleware","debug"],"install":[{"cmd":"npm install monk-middleware-debug","lang":"bash","label":"npm"},{"cmd":"yarn add monk-middleware-debug","lang":"bash","label":"yarn"},{"cmd":"pnpm add monk-middleware-debug","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires monk >=5.0.0","package":"monk","optional":false},{"reason":"peer dependency: requires mongodb driver","package":"mongodb","optional":true}],"imports":[{"note":"ESM default import is correct; CommonJS require works but may not be type-safe.","wrong":"const debugMiddleware = require('monk-middleware-debug')","symbol":"default","correct":"import debugMiddleware from 'monk-middleware-debug'"},{"note":"This package exports a single function as default; named destructure does not work.","wrong":"const { debugMiddleware } = require('monk-middleware-debug')","symbol":"default","correct":"const debugMiddleware = require('monk-middleware-debug')"},{"note":"The default export is unnamed; use any name you like.","wrong":"import { debugMiddleware } from 'monk-middleware-debug'","symbol":"debugMiddleware","correct":"import debugMiddleware from 'monk-middleware-debug'"}],"quickstart":{"code":"import monk from 'monk';\nimport debugMiddleware from 'monk-middleware-debug';\n\nconst db = monk('localhost/mydb');\ndb.addMiddleware(debugMiddleware());\n\nconst collection = db.get('users');\ncollection.find({}).then(console.log);","lang":"javascript","description":"Shows how to add debug middleware to a monk instance and execute a query."},"warnings":[{"fix":"Remove middleware and set environment variable DEBUG=monk:* to see debug logs.","message":"This package is no longer actively maintained; monk has built-in debugging via 'debug' module. Use monk's native debug instead.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Update monk to version >=5.0.0.","message":"Requires monk >=5.0.0; incompatible with older monk versions.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Call db.addMiddleware(debugMiddleware()) immediately after creating the monk instance.","message":"The middleware must be added before any queries are made; otherwise debug logs won't show.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use default import: import debugMiddleware from 'monk-middleware-debug'","cause":"Importing named export instead of default export.","error":"TypeError: debugMiddleware is not a function"},{"fix":"Add parentheses: db.addMiddleware(debugMiddleware())","cause":"Calling debugMiddleware without parentheses, passing the function reference instead of its return value.","error":"Error: Middleware must be a function"},{"fix":"Run npm install monk-middleware-debug","cause":"Package not installed or missing from dependencies.","error":"Cannot find module 'monk-middleware-debug'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}