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

#37652856-Backend api implementation of project CRUD #20

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from

Conversation

tanerochris
Copy link
Contributor

Description

Developing the API backend for creating, updating and viewing of projects on voxnostra,

### How Has This Been Tested?
Tests have been written for the different endpoints

Any background context you want to provide?


### Relevant Task link (from the project board)

Card 37652856

Questions

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have added necessary inline code documentation
  • I have added tests that prove my fix is effective and that this feature works
  • New and existing unit tests pass locally with my changes
    closes Backend API implementation of Project CRUD #14

mernxl and others added 18 commits May 9, 2020 17:23
OpenAPI 3.0 design
Yaml and JSON files

closes #6
- set content type for catchall error response
- workaround for JS Object destructuring inside an if block considered error by codacity
Added instructions to run API endpoint documentation
Added link to external docs

close
@tanerochris tanerochris added the enhancement New feature or request label May 15, 2020
@tanerochris tanerochris added this to the sprint-2 milestone May 15, 2020
@tanerochris tanerochris changed the title 37652856-Backend api implementation of project CRUD #37652856-Backend api implementation of project CRUD May 15, 2020
- Updated readme file
- Added schemas and model related to project feature
- Created an all model file to import into database ,prevents previous error from mongoose "cannot overrite model already compiled"
- Added ApiErrorResponse class to manage api errors
- Wrote tests for Project feature endpoints
- Updated setupTests.js with code to run before and after test suits run
- rename auth directory to user to match docs api endpoints

close #14
- Updated readme file
- Added schemas and model related to project feature
- Created an all model file to import into database ,prevents previous error from mongoose "cannot overrite model already compiled"
- Added ApiErrorResponse class to manage api errors
- Wrote tests for Project feature endpoints
- Updated setupTests.js with code to run before and after test suits run
- rename auth directory to user to match docs api endpoints

close #14
- Updated readme file
- Added schemas and model related to project feature
- Created an all model file to import into database ,prevents previous error from mongoose "cannot overrite model already compiled"
- Added ApiErrorResponse class to manage api errors
- Wrote tests for Project feature endpoints
- Updated setupTests.js with code to run before and after test suits run
- rename auth directory to user to match docs api endpoints

close #14
- added jest options --forceExit --detectOpenHandles --maxWorkers=10 to exit jest when all test pass

close #14
@cliffordten
Copy link

Hey @tanerochris Please could you attach screenshot for test on different endpoints?

@tanerochris
Copy link
Contributor Author

tanerochris commented May 16, 2020 via email

This was referenced May 17, 2020
@tanerochris tanerochris requested review from KaiserPhemi and removed request for dherve19 May 20, 2020 12:01
- documented project api endpoints
- refactored project structure, renamed folders and moved files raised in #16
- added prettier configuration

partially resolve #14 reviews
- documented project api endpoints
- refactored project structure, renamed folders and moved files raised in #16
- added prettier configuration

partially resolve #14 reviews
- documented project api endpoints
- refactored project structure, renamed folders and moved files raised in #16
- added prettier configuration

partially resolve #14 reviews
Copy link
Contributor

@KaiserPhemi KaiserPhemi left a comment

Choose a reason for hiding this comment

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

Critical

  • File Naming: Going forward let's adopt camelCase for naming files as opposed to snake-case that's been used.
  • It appears responses aren't sent for error messages thrown.
  • I noticed we're using res.json() & having to set the header. res.send() automatically sets the header so it's preferable.
  • I might need to schedule a sync with all today(21st May) on this .

* @returns {Promise<void>}
*/
async function SignOutHandler({ req, res }) {
if (req.method === 'DELETE') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick

If this route is meant to specifically handle sign-out (cos the frontend should specifically send delete request in the first place) why check the http method in the first place? Besides I believe all checking/validation should be handle by a middleware.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mernxl could you look into this.

* @returns {Promise<void>}
*/
async function SignUpHandler({ req, res }) {
if (req.method === 'POST') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick

Same thing as the comment I left above.

*/
const IndexProjectHandler = async ({ req, res }) => {
if (req.method === 'GET') {
const limit = req.query.limit || 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick

A better approach would be to abstract these into a helper file or a middleware

@tanerochris
Copy link
Contributor Author

tanerochris commented May 21, 2020 via email

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

Successfully merging this pull request may close these issues.

Backend API implementation of Project CRUD
4 participants