Search code examples
node.jsapiexpressmicroservicesexpress-gateway

Understanding user creation between Express Gateway & Microservices ( or Monolithic API )


I'm in the process of learning and experimenting with Express Gateway and some simple services ( or even just a small monolithic api that sits behind the gateway )

I have gone through Express Gateway 'Getting Started' examples and have read through documentation.

Right now I'm trying to grasp how a user of the system, client/customer, will be created.... The confusion lies in the area where the 'Getting Started' tutorials had me create a user WITHIN Express Gateway.

But coming from a monolithic RESTful API viewpoint... the system may have its own DB schema for what a User is. Client app calls an API endpoint for user creation, goes through its own process, makes the record, returns to the client a successful creation ( or not ). Then getting the user authorized ( JWT / OAuth / etc.. )

So using Express Gateway, do we need to create a user, then pass that ID down to a UserService to save in its own dB, linking this newly created id with the express gateway id ?


Solution

  • That is correct; usually what you want to do when you are creating a new user is to make a call both your database/service and to Express Gateway as well with some of the details so they stay in sync.

    If you do not really want to do that it's advised to use a thirty party service such as Auth0 to keep the identity users decoupled from the user details.

    Does that explain/clarify?