feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.04k stars 751 forks source link

Run Koa Middleware After authentication hook, but before all other hooks #3217

Closed ericuldall closed 1 year ago

ericuldall commented 1 year ago

I have an upload service that uses multer in order to parse files into the request object and then upload them to a storage location of my choosing, it then stores a record of the storage details in the database adapter for that service.

The problem is multer is run as a middleware so i'm using the koa.before to run it which works great, however since it runs before the authenticate hook any user can upload files to my storage bucket (they will get a 401 but not until after the file has been stored).

Is there a way to run the koa middleware after the authentication hook but before the service call?