Skip to content

Completing REST endpoints for GET all and POST#6

Open
Amormio25 wants to merge 1 commit intomainfrom
listings-api
Open

Completing REST endpoints for GET all and POST#6
Amormio25 wants to merge 1 commit intomainfrom
listings-api

Conversation

@Amormio25
Copy link
Collaborator

Describe your changes

[ Couple of bullet points ]

  • worked on GET all and POST methods for listings

I have a couple questions about my implementation.
First off from the deliverables it said the schema should have the _id field. Just wondering how that would work since I wasn't sure if researchers would be the one providing the ids of their listings or we will.
Should we allow a listing with quantity as 0?
Then more of a developer choice, am I right to assume we shouldn't be displaying error information about our endpoints to users, just send a short readable message?

I had some of these questions commented in my code.

Issue ticket number and link

[ Insert Link & Ticket #]

Checklist before requesting a review

  • [ x] My code follows the style guidelines of this project
  • [ x] I have performed a self-review of my code
  • [x ] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • [x ] My changes generate no new warnings
  • [ x] I have added tests that prove my fix is effective or that my feature works
  • [ x] New and existing unit tests pass locally with my changes
  • This change requires a documentation update

_id: z.string().min(1),
itemId: z.string().min(1),
labId: z.string().min(1),
quantityAvailable: z.number().min(0), // can list items with 0 quantity?
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should have items listed with min of 1 quantity

import Listing from "@/models/Listing";

// test comment
// ask about whether users should provide _id, that seems more like a
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't include _id field since MongoDB will automatically generate and it is a db thing. I was a bit unclear in the task description, but yes, we shouldn't have a id field.

}
}

// get all
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: method headers should have a detailed comment about what it does. What is the input? output?

Copy link
Collaborator

@arnavjk007 arnavjk007 left a comment

Choose a reason for hiding this comment

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

I noticed this is on a different branch than the schema; we should have each service on its own branch, not each task. We can have everything related to listings in one branch, so schema and api changes would be done in the same branch. Please move these changes to the original listings branch and check if you can rename the branch to something like "listings_svc"

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.

2 participants