devconcept / multer-gridfs-storage

🍃 GridFS storage engine for Multer to store uploaded files directly to MongoDb
MIT License
237 stars 67 forks source link

Latest version overwrites MongoDB types affecting other packages, i.e. connect-mongo #502

Open onebrother21 opened 2 years ago

onebrother21 commented 2 years ago

Describe the bug Version 5.0.2 overwrites mongoDB/mongoose types that break other mongoDB/mongoose-dependent packages, like connect-mongo. Not sure which set of types are actually doing the harm.

Environment

To Reproduce npm i connect-mongo -> package.json shows "connect-mongo": "^4.6.0"; npm i multer@1.4.4-lts.1 -> package.json shows "multer": "^1.4.4-lts.1"; npm i multer-gridfs-storage -> npm shows warnings/errors addressed in #490 , package.json shows "multer-gridfs-storage": "^5.0.2".

Upon build, the following errors are generated:

tsc

node_modules/connect-mongo/build/main/lib/MongoStore.d.ts:2:55 - error TS2305: Module '"mongodb"' has no exported member 'WriteConcernSettings'.

2 import { Collection, MongoClient, MongoClientOptions, WriteConcernSettings } from 'mongodb';


node_modules/mongoose/types/aggregate.d.ts:22:25 - error TS2694: Namespace '"C:/Users/servi/Desktop/d-drive/cctx/oba-express/node_modules/@types/mongodb/index"' has no exported member 'CollationOptions'.

22     collation?: mongodb.CollationOptions;

node_modules/mongoose/types/aggregate.d.ts:36:23 - error TS2694: Namespace '"C:/Users/servi/Desktop/d-drive/cctx/oba-express/node_modules/@types/mongodb/index"' has no exported member 'ExplainVerbosityLike'.

36 explain?: mongodb.ExplainVerbosityLike;

And 60 more...The build command output ends with this summary:

Found 63 errors in 11 files.

Errors Files 1 node_modules/connect-mongo/build/main/lib/MongoStore.d.ts:2 9 node_modules/mongoose/types/aggregate.d.ts:22 3 node_modules/mongoose/types/collection.d.ts:8 4 node_modules/mongoose/types/connection.d.ts:75 1 node_modules/mongoose/types/error.d.ts:37 1 node_modules/mongoose/types/index.d.ts:467 7 node_modules/mongoose/types/indexes.d.ts:18 26 node_modules/mongoose/types/models.d.ts:23 8 node_modules/mongoose/types/query.d.ts:103 2 node_modules/mongoose/types/schemaoptions.d.ts:43 1 node_modules/mongoose/types/session.d.ts:4

Expected behavior Upon build, no errors generated. When this package is removed only, build runs perfectly as expected.

devconcept commented 2 years ago

I guess hardcoding the version of the types "@types/mongodb": "^3.5.25" is a problem. Will fix it soon

onebrother21 commented 2 years ago

Just checking in on progress. Any ETA?

judaschwartz commented 3 months ago

It looks like this was fixed and merged to master 8 months ago https://github.com/devconcept/multer-gridfs-storage/commit/41685efff865f8098c43e6d461ec3f4c086c86f1 Is there a reason why a new release has not been created for this?

devconcept commented 3 months ago

Hi. Multer decided to nuke storages for the new version. If that is the case there is not a lot of purpose for this module. I think is a bad idea but nothing stops multer for making a bad decision. In fact they are still stuck in the .lts-1 version and not releasing a minor version or the major so is not clear what is going to happen. This is why I stopped developing to see what would happen. I can release a new major version with all the fixes but due to incompatibilities with mongodb versions I have to rewrite a lot and also multer can publish a new major version and force me to rewrite again. I hope you can understand my position. I've been thinking on releasing as it is lately. Please understand that this is a plugin and it depends of what is decided on the parent module.