lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.54k stars 499 forks source link

Add ability to inject our custom multer instance to tsoa #1483

Closed lalchan closed 3 months ago

lalchan commented 1 year ago

Sorting

Expected Behavior

Ability to add my own custom multer instance to the tsoa instance as follow:

const multerInstance: Multer.Multer = multer({ ...your config here});

// it could be something like
RegisterRoutes(app, {
    multer: multerInstance
});

since above method seems out of scope for the RegisterRoutes function, we could do something like

RegisterMulter(multerInstance);
RegisterRoutes(app);

the above code would provide tsoa with the themulterInstance which it would use as it's multer instance instead of initializing it's own multer instance.

Current Behavior

Although we can customize the multerOpts using the tsoa.json, it seems to be incomplete as it is incapable of inserting storage engine to the multerOpts, rightfully so as it is a json file. This has caused some issue when i wanted to use multer-s3 as the storage engine for multer and also maintain the single truth in controller idea.

Possible Solution

See Expected Behaviour

P.S. I am new here, if I broke any rules, i apologize in advance.

github-actions[bot] commented 1 year ago

Hello there lalchan šŸ‘‹

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.šŸ‘€

WoH commented 1 year ago

Would you like to submit a PR for this? We can probably even deprecate the old way in this case, which is more flexible. For convenience, the api should probably be RegisterRoutes(app, {multer}), I like that suggestion

lalchan commented 1 year ago

Since I am new to this, I don't know what responsibilities submitting a PR include, will be submitting a PR as soon as I am available to work on this.