Closed the4t4 closed 2 years ago
@Abdulla-Alkhulaqui the frontend is failing to build with this error:
Do you have any idea what this is?
@the4t4 Just three main things to point out:
1) The first one is we still need the exports for all the utils functions since the backend can utilize whatever it needs from this database_utils.ts.
2) The call of a promised function in the utility requires the await
keyword before it since they return promises. Promises can be thought of as individual threads. The behavior of the database endpoints that you defined is unpredictable. So for instance, in insertIntoTable('section', req.body);
and the line underneath it: res.status(200).send(JSON.stringify({message: "New section added"}));
. This will return status 200 no matter if the insertIntoTable() is valid or not. The paradigm I use is that I always return a result (QryResult) that has the result or the error.
3) In the future, there must be validation layers such that a demonstrator, only, can add a section to his assigned group and no other group. However, the current getUserKeycloak
is not returning the roles. Therefore, I skipped that part. However, if you want to make sure that this is almost complete, you need to add at least a validation layer that the user (no matter the role for now) can alter only his specified groups/sections/tasks.
@Mohido
@the4t4 1) The most useful use-case would be if we need to implement some other utility that relies on this utility to function. That utility will be in TS since its the standard for implementing our utilities (more robust). Other things are minor use-cases. However, for me I would love to export everything in the utilities to the backend and the backend developer can deal with it (Unless it is a secret configuration maybe?) . Having this standardized help the other developers that will come after us.
2) Yes you are correct regarding that one. It will always return 200. Not a big deal for now, since the front-end was off for testing
3) Gotcha mate
@Mohido ready for review
For now, this looks all fine. I have no comments other than the distribution of the API endpoints must be function-specific and not server-application-specific.. So we only have: 1 file for /users/ and 1 file for /tasks/ and another one for /sections/ Instead of db.js. However, code ordering can come in the next PR. For now let's merge this one to the development branch.
Added the following endpoints:
None of them have been tested yet because the frontend is failing the application. The database has been updated, but not yet completely to match the requirements of #52