Skip to content

Commit

Permalink
Merge pull request #458 from T-vK/main
Browse files Browse the repository at this point in the history
Fix support for modelFactory
  • Loading branch information
florianholzapfel authored Mar 8, 2024
2 parents f0a67d4 + 0d71d47 commit 934e66a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "express-restify-mongoose",
"version": "9.0.1",
"version": "9.0.2",
"description": "Easily create a flexible REST interface for mongoose models",
"keywords": [
"ReST",
Expand Down
10 changes: 7 additions & 3 deletions src/express-restify-mongoose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ export function serve(
app.delete = app.del;
}

app.use((req, res, next) => {
req.erm = {};

app.use(async (req, res, next) => {
const getModel = serveOptions?.modelFactory?.getModel;

req.erm = {
model: typeof getModel === 'function' ? await getModel(req) : model,
};

next();
});

Expand Down

0 comments on commit 934e66a

Please sign in to comment.