joelbrs / bank.com.br

https://bank.joelf.tech
3 stars 0 forks source link

[Question] Whats the logic of using a idempotency key from the header and where do you create this key? #11

Open caiocampoos opened 3 months ago

caiocampoos commented 3 months ago

https://github.com/joelbrs/bank.com.br/blob/main/apps/server/src/get-context.ts#L19

joelbrs commented 3 months ago

Whats the logic of using a idempotency key from the header?

The idempotency key is a control information to prevent that twice or more transactions will be created. That is why I believe that information has to be sent in Headers.

Where do you create this key?

The idea is to front-end generate a valid UUID every time an user access the create transaction page and that UUID will be passed to backend in header as known.

By the way, I am opened to receive another suggests!! \o/

caiocampoos commented 3 months ago

But where is this key on the code? I can see the header but i can't find where you are generating the key. The most important part of a idempotency Key is its composition, where is generated is debatable, but how you compose the key will dictate if it is really idempotent.

joelbrs commented 3 months ago

I haven't done it yet. First, I have to reorganize the frontend structure where I made the relay calls to backend. I aim to do it tonight, because now I have to attend some demands at work. When I finished it, I'll make a PR specific to this issue.