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

PUT / Update Community-Event API #107

Conversation

anjolaoluwaakindipe
Copy link
Collaborator

@anjolaoluwaakindipe anjolaoluwaakindipe commented Jun 26, 2023

Created the update API following the structure created by @1234tgk and also added validation to the to the update api to prevent invalid user requests

Example of Request:

Post request created by @1234tgk on the left and put request created by me on the right
Screenshot 2023-06-26 at 1 45 47 AM

Additions

  1. Added Zod as a dependency in the backend
  2. Added a new error handling middleware which helps handle all types of errors both Custom and Unexpected src/middleware/errorHandler.ts
  3. Added various Custom Application Errors src/utils/errors that can be used to throw Custom Errors within the application with already configured status codes. e.g BadRequestError, InternalServerError, ConflictError, UnauthorizedError, and NotFoundError.
  4. Created a flexible validation parser function that validates requests based on any schema it is given and returns back the request (with type-safety based on the schema) if validation is successful, else throws an application error (BadRequestError) (src/utils/validation/validationParser.ts)
  5. Added JsDoc comments in a few files
  6. Renamed some of the exports and imports to be more explicit. e.g

Before:

export default {
   create: (req, res) => {...}
}

After:

const communityEventController ={
    create: (req,res) => {...}
}
export default communityEventController

Copy link
Contributor

@0916dhkim 0916dhkim left a comment

Choose a reason for hiding this comment

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

Looks great! I love the validation system 👍
I left some suggestions below, so let me know what you think.

server/package.json Show resolved Hide resolved
server/prisma/migrations/20230623053743_init/migration.sql Outdated Show resolved Hide resolved
server/src/middleware/errorHandler.ts Outdated Show resolved Hide resolved
server/src/modules/community-event/controller.ts Outdated Show resolved Hide resolved
server/src/modules/community-event/service.ts Outdated Show resolved Hide resolved
server/src/modules/community-event/validations/index.ts Outdated Show resolved Hide resolved
server/src/utils/errors/index.ts Outdated Show resolved Hide resolved
server/src/utils/validation/validationParser.ts Outdated Show resolved Hide resolved
@igMike-V
Copy link
Collaborator

When we create a new event can we set the POST to have nobody? We should create a new empty event and then immediately load it into an event edit page to fill in the details.

So we would need only to return the id on the creation of an event.

What does everyone think?

@igMike-V
Copy link
Collaborator

just looked further at the code. Looks like what I just posted would work based on the validation schema

@anjolaoluwaakindipe
Copy link
Collaborator Author

When we create a new event can we set the POST to have nobody? We should create a new empty event and then immediately load it into an event edit page to fill in the details.

So we would need only to return the id on the creation of an event.

What does everyone think?

So should we make the requirement of a community event needing a user(organizer) optional for now?

@0916dhkim
Copy link
Contributor

@igMike-V That is a good point 👍 I'll merge this PR and have the following issue for the fixes.

@0916dhkim 0916dhkim merged commit b474e95 into EOT-Event-Organizer-s-Toolbox:main Jun 29, 2023
1 check failed
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.

4 participants