0

I am quite sure that I am not the first person on the planet trying to implement the following, but I am sure that I am not able to find a good guide how to do it.

Our node backend is setup quite like a MVC to say so.

View = Express Server offering our api

Controller = Library, a set of controller functions to manage our data

Model = Our mysql database, it's Javascript DAO respectively (since our usecase is quite unique we need to write own DAO's and can not go let's say for js-data.

The challenge we face now, is:

  • As a developer, I want to keep our library clean from overhead for developers.
  • On the other side, as a database administrator I clearly want to know who did what modification and so on

Until now I tried to keep the 'user' object out of the library, since I do not want all controller functions to look like

function ctrl(param1, param2, param..., user)

Going for this would mean, we have to pass around User objects all the time, which would make it a pain to code inside the libraries.

On the other hand, I can not find any other approach in node/express to somehow get knowledge about the user without passing it (since we do not really have sessions, at least not yet in our code).

TL:DR; I do want to action log all database modifications, but do not want to pass around a User object all the time.

Is there any known approach for that challenge which does scale and is 'best practice'?

Thanks in advance

mambax
  • 1,079
  • 8
  • 17

0 Answers0