feathersjs / feathers

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

fix(core): context.path is now typed correctly #3303

Closed AshotN closed 9 months ago

AshotN commented 9 months ago

Summary

Currently app.service() is typed to all the registered services, and since context.path is just a string doing app.service(context.path) in a hook leads to an error that string is not assignable to <list of schemas>

This issue resolve that by allow context.path to check against the service provided in the HookContext. If HookContext is not typed with a service, it will default back to all services.

If you create a hook in your user service. Where the context.path should always be user. It should not be typed as such

If you create a global hook, context.path will be a intersection of all your registered services.

daffl commented 9 months ago

That's a great change, thank you!