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

express-mongoose-resolve

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-mongoose-resolve

flexible express middleware which resolves mongoose model by id specified via params and assigns it to req.resolved

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-84.62%
Maintainers
1
Weekly downloads
 
Created
Source

express-mongoose-resolve

Install

npm i express-mongoose-resolve

Example

const resolve = require('express-mongoose-resolve');
const Model = require('./models/Model');
...
router.get('view/:model', resolve(Model), (req, res) => res.json(req.resolved.model));

API Reference

resolve(model, options) ⇒ function

Configures and returns middleware listener which will resolve model instance from request params and assign it to "req.resolved" Object using lowercase name of the model, so such middleware:

...get('/foo/:vod', resolve(Vod))

will save model as req.resolved.vod

You cannot alter this behavior

ParamTypeDescription
modelobjectmongoose model
optionsobjectoptions
Options
KeyTypeDescription
paramNamestringreq.params object property key
composeConditionfunctioncallback which will return custom query condition from request params
indexstringname of model index to query against (if composeQuery is String)
prepareQueryfunctioncallback, which will alter query according to request query flags

Keywords

FAQs

Package last updated on 17 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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