Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for CJS and add support for Mongoose 8 (and MongoDB 7) #456

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

T-vK
Copy link
Contributor

@T-vK T-vK commented Mar 7, 2024

This PR fixes #453 and #454. I've tested it with CommonJS and ESM. Build, Test, Lint etc. are working fine too.

Notable changes

Regarding #453:

  • Fixed support for Common JS. (express-restify-mongoose 8 broke support for CJS, meaning it could only be used with import (ESM) and not with require (CJS) anymore)
  • Downgraded serialize-error to ^8.1.0 and dot-prop to ^6.0.0 in order to add support for CJS again.
  • Removed ESM build (because CJS automatically supports ESM as well and swc is lacking in features to properly build a dual module)
  • Had to switch to .mjs extension to allow tests to keep using import
  • Fixed version of eslint-plugin-mocha to 10.3.0 because with 10.4.0 the minimum node version was increased to 18.
  • Removed "type": "module" from the package.json (necessary to support CJS)
  • Bumped ERM version to 9.0.0

Regarding #454:

  • Uses Mongoose 8 by default now (adding support for MongoDB 7)
  • Supports Mongoose 7+8 in addition to what was supported before
  • Minimum required node version increased to 16 (requirement for Mongoose 8)
  • Since Mongoose 7 and 8 dropped support for callbacks, I had to rewrite some of the code into the promise syntax.
  • Mongoose 7+8 also deprecated and removed some functions which therefore had to be replaced. E.g. .findOneAndRemove() and .remove()...
  • In one test I had to do add delete body.errors.customer.message; in order keep support for older Mongoose versions, which in my opinion doesn't have a negative impact.

@T-vK
Copy link
Contributor Author

T-vK commented Mar 7, 2024

@florianholzapfel @Zertz I'd love to get this merged soon if possible. :)

@florianholzapfel florianholzapfel merged commit 575c4ae into florianholzapfel:main Mar 8, 2024
16 checks passed
@florianholzapfel
Copy link
Owner

thanks for the awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Common JS is broken with v8
2 participants