Refactor enrollments route to include query building
Changes:
- Add error handling in the database query function. When a database error occurs, it is logged in the server and a plain text response is returned to the user.
- Implement building of SQL queries inside the API, which removes the need to have stored functions/procedures on the database, since the former approach is not flexible or efficient to maintain/extend.
- Use route chaining to determine which function will build the query that needs to be executed. The last function is the one that actually sends the query to the database and send the response.
Future Work:
- Instead of returning a plain text response, return a HTTP 501 status, which is currently not possible. When one attempts to send such status the framework throws an error that the headers were already sent for the current request.
- Chaining based on the route might not be the best solution here.
Merge request reports
Activity
@jvtr12 The future work described will be part of this merge?
Added 1 commit:
- 8d77d014 - Add education level and fix issue with adm_dependency_id
To respond with a HTTP 501 status the error check must be on the first function from the chain.
@vsbc14 So one would have to pull the database query to the first function in routing function chain? If that is the case, then implementing the query building separately and just have one function for the route executing the query is a good way to go.
Added 1 commit:
- 00a87dec - Change API to use ECMAScript6
Added 1 commit:
- 2e3dc702 - Add installing the packages globally in .gitlab-ci.yml
Added 1 commit:
- 53dfb7a1 - Change installing gulp via apt-get command for npm
Added 1 commit:
- 30fda4ed - Add mocha to .gitlab-ci.yml
Added 1 commit:
- 029f378b - Fix city query by IBGE code route
@jvtr12 Actually, I was wrong. No need to send the response in the first function, I've got it working as was responding the correct error status code.
But I still think that building the query separately is a good way to go.
@vsbc14 I'll proceed working on building and executing the queries, and the API response into different components. Probably looking into the Promise object to implement these functions in chain might be the ideal solution.
Added 8 commits:
-
373934dd...55ff5eca - 7 commits from branch
development
- bb074395 - [wip] Refactor Query
-
373934dd...55ff5eca - 7 commits from branch
Added 1 commit:
- d7885f74 - Merge routes from cities.js into city.js
Added 6 commits:
Toggle commit listAdded 1 commit:
- d905b17f - Add skeleton for basic dev tasks in gulpfile