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

Added Controller for getArticle and getArticlebyID #18

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

richartothman
Copy link

We have created a controller for the articles get function, but there is a slight problem, the GET request does not return an error, however, get article returns an empty array [] and get article by id returns nothing. We are not sure if our function is wrong.

src/database/controllers/article.controller.ts Outdated Show resolved Hide resolved
src/database/controllers/article.controller.ts Outdated Show resolved Hide resolved
src/app.module.ts Outdated Show resolved Hide resolved
@david20571015
Copy link
Collaborator

You can try to improve the readability by re-implementing the post-processing steps instead of just copy and paste.

Copy link
Collaborator

@david20571015 david20571015 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please find out how we fetch data from the DB (filter and option) and how we process the result after getting the data in v1.
  2. I noticed you used console.log to print some information, but in practice, you should use logger. And since we haven't decided what should be logged, you could simply remove all console.log.
  3. Keep the Service as general as possible because it might be called by various functions.
  4. It is better to integrate the code related to the article into ArticleModule (please create a new file), and import it to AppModule.

src/database/article.service.ts Outdated Show resolved Hide resolved
src/database/article.service.ts Outdated Show resolved Hide resolved
src/database/article.service.ts Outdated Show resolved Hide resolved
src/database/controllers/article.controller.ts Outdated Show resolved Hide resolved
src/database/controllers/article.controller.ts Outdated Show resolved Hide resolved
src/database/controllers/article.controller.ts Outdated Show resolved Hide resolved
src/database/controllers/article.controller.ts Outdated Show resolved Hide resolved
src/database/controllers/article.controller.ts Outdated Show resolved Hide resolved
@david20571015
Copy link
Collaborator

It's almost complet.

To ensure that your code is correct, try writing some unit tests for the controller and end-to-end tests for the APIs. If you're unsure how to proceed after reading the documentations below, you can reference the codebase in /test (though it's not entirely complete) or ask ChatGPT for assistance.

Ref:

@NicoA07 NicoA07 force-pushed the article_controller branch from e5ada87 to c4475c4 Compare May 22, 2024 08:10
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.

3 participants