{"id":18571,"library":"monk-middleware-handle-callback","title":"monk-middleware-handle-callback","description":"This package provides a middleware for monk (a MongoDB driver for Node.js) that automatically handles callbacks in query pipelines. Version 0.2.2 is a very old, unmaintained package specifically designed for older versions of monk (pre-v5). It is not compatible with modern monk versions (v5+). The release cadence is unknown and likely abandoned. Key differentiator: it simplifies callback handling in monk middleware chains, but is superseded by monk's native Promise support.","status":"deprecated","version":"0.2.2","language":"javascript","source_language":"en","source_url":"git://github.com/Automattic/monk","tags":["javascript","monk","middleware","callback"],"install":[{"cmd":"npm install monk-middleware-handle-callback","lang":"bash","label":"npm"},{"cmd":"yarn add monk-middleware-handle-callback","lang":"bash","label":"yarn"},{"cmd":"pnpm add monk-middleware-handle-callback","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: this middleware is designed to work with the monk package.","package":"monk","optional":false}],"imports":[{"note":"This package uses CommonJS and does not support ESM imports.","wrong":"import handleCallback from 'monk-middleware-handle-callback'","symbol":"handleCallback","correct":"const handleCallback = require('monk-middleware-handle-callback')"}],"quickstart":{"code":"const monk = require('monk');\nconst db = monk('localhost/mydb');\ndb.addMiddleware(require('monk-middleware-handle-callback'));\nconst collection = db.get('users');\ncollection.insert({ name: 'John' }, function(err, doc) {\n  if (err) console.error(err);\n  else console.log('Inserted:', doc);\n});","lang":"javascript","description":"Shows how to use the handle callback middleware with monk to simplify callback-based queries."},"warnings":[{"fix":"Remove middleware and use monk's built-in Promise API: await collection.insert(doc)","message":"Package is deprecated and unmaintained since 2016. Consider using monk's native Promise support or async/await instead.","severity":"deprecated","affected_versions":"all"},{"fix":"Upgrade to monk v5+ and remove this middleware dependency.","message":"Incompatible with monk v5+ because monk changed its middleware API and now uses Promises natively.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Ensure you are using callback syntax when this middleware is registered.","message":"The middleware only works with callback-style monk methods (pre-v5). If you use Promises, the middleware will not be invoked.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Remove the middleware usage; monk v5+ does not support custom middleware.","cause":"monk v5+ removed the addMiddleware method.","error":"TypeError: db.addMiddleware is not a function"},{"fix":"Use monk v4 or lower, or remove this middleware entirely.","cause":"The middleware expects a specific signature that is not provided by monk v5+.","error":"Error: Middleware must accept three arguments"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}