monk-middleware-handle-callback

raw JSON →
0.2.2 verified Sat Apr 25 auth: no javascript deprecated

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.

error TypeError: db.addMiddleware is not a function
cause monk v5+ removed the addMiddleware method.
fix
Remove the middleware usage; monk v5+ does not support custom middleware.
error Error: Middleware must accept three arguments
cause The middleware expects a specific signature that is not provided by monk v5+.
fix
Use monk v4 or lower, or remove this middleware entirely.
deprecated Package is deprecated and unmaintained since 2016. Consider using monk's native Promise support or async/await instead.
fix Remove middleware and use monk's built-in Promise API: await collection.insert(doc)
breaking Incompatible with monk v5+ because monk changed its middleware API and now uses Promises natively.
fix Upgrade to monk v5+ and remove this middleware dependency.
gotcha The middleware only works with callback-style monk methods (pre-v5). If you use Promises, the middleware will not be invoked.
fix Ensure you are using callback syntax when this middleware is registered.
npm install monk-middleware-handle-callback
yarn add monk-middleware-handle-callback
pnpm add monk-middleware-handle-callback

Shows how to use the handle callback middleware with monk to simplify callback-based queries.

const monk = require('monk');
const db = monk('localhost/mydb');
db.addMiddleware(require('monk-middleware-handle-callback'));
const collection = db.get('users');
collection.insert({ name: 'John' }, function(err, doc) {
  if (err) console.error(err);
  else console.log('Inserted:', doc);
});