diia-open-source / be-user-service

European Union Public License 1.2
136 stars 6 forks source link

Backend: Code style: long expressions with await #81

Open tshemsedinov opened 3 months ago

tshemsedinov commented 3 months ago

It is much better to use intermediate variables instead of such a long expressions, even more... with await in the middle

https://github.com/diia-open-source/be-user-service/blob/b45a0e2db354df110a99254516a414aaac43be61/src/services/diiaId.ts#L112-L113

DiiaOpenSource commented 3 months ago

Thank you for your attention @tshemsedinov. An expression with two operations is not long. It's a common approach to assigning a default value when a parameter is not provided. Our team prefers this approach for default values instead of re-assignments with let declarations. In other situations, when things are more complicated than substituting default values, we do not use such expressions with await inside.