im building a PWA app , where i implemented jwt token to auth users.
i have 2 main architecture problems ,but let me introduce you what im building .
i'm Building application that is all about dog lovers , this application is to post lost dogs, post dogs for an adoption , for dog owners to find a good dog services around them like vets and dog walkers etc
in my application you are registering with Facebook or Google,
in my application any user can open up services , if you are a dog walker you can easily open up a service fill in some basic stuff and people all around can find this new service .
i got [ auth , user , chat , association , dog , haircut, review , store , trainer , vet ,walker ] = micro services
i am planing to run it on Aws Ecs.
1st problem : JTW stay Outdated if i dont talk to Auth service and Re generate token for a user .
if user register new vet service, i must return him also a new access Token , or else his JWT token will be outdated with his old information that will not has that information about the newly created service.
right now im letting the micro services to talk between them and i really dont like this idea because i can easily get lost with debugging and logging them.
this is how creating new service look now
*each microservice holds in his ENV the key to read the JWT
User >
walkerService (creating new service) userService (updating User property "services" field with the new services pointer id) user object has "services" object inside , its has arrays that hold pointers to serviceDb authService (generating new updated access Token)
so what now ? each time user will do update or create service i should return new JWT ?
i can fix it using API GATEWAY , but ...
2nd problem
if i create an api micro service, Api gateway , and move some of the logic into there i feel like im back into a monolith app , in api gateway i can do all stuff related to auth and actually remove the auth service at all , i can "bypass" the problem of direct talk between micro services because i can await for each micro service to finish his task before continue to the next task of the next micro service .
but then the api gateway become more logical and less simple like he should be with just auth , some throttle and routing around micro services...
For example , When in front end if you are watch a post of adoption ,
you actually looking at a document from the "dog" services , but , there also a field of owner (giving private name of the person who actually post this),
in the dog document i have for example the owner id
"dh83db34u9f" : { ownerId: "d236d8g2d83d4", dogName: "Maya", dogAge: "Etc.." }
so , before i return this document from the dog service , i also need to attach it the name of the owner so i need to ask from the "user" the public info for this user
and only then , combine this 2 into 1 object and Response to the Call...
i believe this api gateway shouldn't do stuff like that , so i wonder should i create new service just for "crud" / "actions" ?