coding-blocks / judge-api

7 stars 27 forks source link

fix: add lang validators in baseValidator #69

Closed prabalsingh24 closed 4 years ago

prabalsingh24 commented 4 years ago

fixes #65

prabalsingh24 commented 4 years ago

@championswimmer @jatinkatyal13 what do you think of this approach? Since lang is required in all the routes. I fetched it from DB in the start and stored in res.locals.langs.

jatinkatyal13 commented 4 years ago

Fetching from DB is not a heavy operation given the number of rows will be very limited. Eager loading it means increased complexity and you would require a server restart if a new language is added

prabalsingh24 commented 4 years ago

you would require a server restart if a new language is added

langs are fetched everytime for each request. Just like API key of each request are verified. langs are also updated in res.locals.langs in each request

https://github.com/coding-blocks/judge-api/blob/4cb71a4ab43f8f7448dc2b70f21e2ce5021c42d4/src/routes/api/index.ts#L29

jatinkatyal13 commented 4 years ago

We may or may not need langs in each request. E.g. polling

Performance improvements are not significant and in most cases worse with respect to the complexity introduced. Although a nice effort but closing this for now.