-
Notifications
You must be signed in to change notification settings - Fork 3
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
GET cohort by id #41
GET cohort by id #41
Conversation
I created query function which search for cohort based on id which came from params, and I created the necessary middleware for this function to work in addition to handling the required /cohort/:cohortid route Relates #19
I created query function which search for cohort based on id which came from params, and I created the necessary middleware for this function to work in addition to handling the required /cohort/:cohortid route Relates #19
@@ -0,0 +1,21 @@ | |||
const { | |||
cohort: { getSpecificCohort }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest making destructure of getSpecificCohort in /database/queries/index
as :
const { getSpecificCohort } = require('./cohort');
module.exports = { getSpecificCohort };
as you make in server/database/queries/cohort/index.js
file,
and here in this file you can make require to getSpecificCohort as
cohort: { getSpecificCohort }, | |
const { getSpecificCohort } = require('../../../../database/queries'); |
so we get more benefit from /database/queries/index
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I Add a comment in server/controllers/routes/user/cohort/getSpecificCohort.js
and in
server/controllers/index.js
note that destructure point exists in more than one file
test/index.test.js
Outdated
|
||
const app = require('../server/app'); | ||
|
||
beforeAll(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need return
here 😉
beforeAll(() => { | |
beforeAll(() => dbBuild()); |
} catch (err) { | ||
res.status(404).json({ | ||
statusCode: 404, | ||
message: "Sorry There's no cohort for this id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we need to handle server error
66c4241
I created query function which search for cohort based on id which came from params, and I created the necessary middleware for this function to work in addition to handling the required /cohort/:cohortid route
Relates #19