Model Finder Middleware
(require("model-finder"))(req, res, next)
Model Finder Middleware
Evaluates req.params.model (i.e. /api/v1/:model/) and returns an instance of the specified model.
Because node require is cached, the instance will only be created once, no matter how many times a model is called for.
In the event the model is not found, node will throw a "MODULE_NOT_FOUND" error which the error middleware in the server will pick up.
Parameters:
Name | Type | Description |
---|---|---|
req |
object | Express Request Object |
res |
object | Express Response Object |
next |
function | Express middleware next() |
- Source:
- Source: