Search code examples
feathersjs

FeathersJS feathers-hooks-common add userId hook


I'm using FeathersJS to build an app. I want to add userId in many services create requests, so that the already authenticated userId is added to the data created by the service. I know I can create a hook myself, but as I think this sounds as a common problem/requirement in many apps, I thought it should/could be done using someone of all the hooks available in feathers-hooks-common package.

So my question is, how to use feathers-hooks-common to add the userId in the data provided with service create request?

Thank you!


Solution

  • Just for someone that faces the same problem, I've discovered the FeathersJS feathers-authentication-hooks package that solves the problem with 3 different hooks that can be used to add/restrict the queries to the authenticated user.