BEOpenSourceCollabs / EventManagementCore

Event management system collaboration project for the Backend Engineering discord.
Apache License 2.0
3 stars 1 forks source link

added events and resolved issue #17 #24

Closed TejaswinSingh closed 3 months ago

awpt1mus commented 3 months ago

This is good start , I see following things though ,

  1. in events repository in Select.. queries please add explicit column names instead of * , the order of columns returned by the query has to exactly match the arguments order passed to Scan() , this might lead of unexpected bugs.

  2. in event route handlers please use the existing utility function that responds with json i.e utils.WriteErrorJsonResponse and utils.WriteInternalErrorJsonResponse etc. you can refer auth route handlers for understanding usage.

  3. in event route handlers , please use the utility functions for reading json, it handles all common json errors instead of directly using json.NewEncoder , take a look at utils.ReadJson & utils.WriteRequestPayloadError functions , you can refer to auth route handlers for understanding the usage.

  4. Use route handler -> service -> respository flow , at the moment all the logic of creating / updating / deleting events is directly inside the route handler plus the request body is directly being read into map[string]interface{} please move that logic into a service and use separate structure to read request body (DTO) instead of directly using the map[string]interface{}, again you can refer to this pattern in auth module.

  5. Currently there is no validation being done on request body, once you create DTOs you can add validation using the pkg validator , we are using it to perform struct validation , refer to auth module for the same.

  6. all the routes in events module need to be protected (meaning the request needs to come from authenticated user) , currently they are all public, you can use the ProtectMiddleware to wrap the route handler and read the current user using the context , refer to auth module for the same , you can check HandleCheck handler in auth route for this.