Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node Course Test: Pablo Velazquez #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pablocho88
Copy link

@pablocho88 pablocho88 commented Mar 21, 2019

Name: Pablo Velazquez

Explain your solution

Tell us how you solved each of the excercises.

Excercise 1 - Add filter by technologyId for GET /courses endpoint

First i made the initial tests structure and then coded some test for filtering courses by technologyId.
Next Just added the attribute technologyId to filterFields array in courses controller and the tests ran satisfactorily
Problems:

  • Just a litle complicated coding the initial test structure.

Excercise 2 - create a GET /admin/billing/getInvoices

Firts i made some adjust to initial data loaded on test-db and coded some test looking for expected results.
I decided to compare the test request against the already working original request /api/admin/billing/getChargeableStudents
Then i started working on endpoint /admin/billing/getInvoices in controllers/billing.js
I had some doubts about refactoring the function getChargeableStudents for be available to use without request it via API, but finally decided to not refactoring and coded another promise based function using request module of nodeJS. Request module is required on app.js an then passed by parameter to the controller.
Problems:

  • Building the request url for calling /api/admin/billing/getChargeableStudents and /api/afip. I'm not sure yet about the resolution of that.
  • Anidation of promises on initial test structure, so i decided to rework it using an async/await style
  • Some troubles on AFIP API request retry on fails. Finally solved with recursion.

Excercise 3 - Add Middleware for caching GET requests

In this issue i just started coding the middleware without test coz no ones came to my mind. i had some doubts about overriding the helper function res.response200, i feel like its very dangerous.
The solution consist on a <Key,Value> array with GET request as keys and response data as values. On each GET request we find first on cache and returns the value if is found, if not then pass to next() and the overrided res.response200 will cache the response for the next request.
Finally when a PUT o POST request is received the middleware deletes the keys from the cache asociated with that invidual resource and with all the list/find endpoints of that resource type.
Problems:

  • Blank mind on tests building. Finally coded two tests: one expecting that the response time for a first GET request should be minor than the second one and another expecting that a third GET request called after a PUT request will had a higher response time than the second GET request

Excercise 4 - create GET /stats/failuresByStates

Started building a simple test on the endpoint /stats/failuresByStates
Added the stats controller with a function failuresByStates. Solving this one, i fell in love with the reduce function of arrays.
Problems:

  • As an Experienced SQL developer i had some problems building a Query and understanding how to fetch data relationing one document to others. Maybe the Data Models Structure was not the best to aproach this task.

Share your ideas about the application

  • Would you change anything about how the app was designed?
    Some doubts about Data Modeling: Why no relations between schemas?

  • What else would you add to it?
    Its okey for me. The excercises are fun and challenging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant