Skip to content

Commit

Permalink
Merge branch 'main' into 188-make-all-users-follow-sac-super-club
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye authored Feb 26, 2024
2 parents b1f1b46 + a1a8f0a commit 346105e
Show file tree
Hide file tree
Showing 42 changed files with 1,457 additions and 1,665 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ sac-cli
node_modules
.vscode
.trunk
.env.dev
4 changes: 2 additions & 2 deletions backend/src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
EnvironmentProduction Environment = "production"
)

func GetConfiguration(path string) (*Settings, error) {
func GetConfiguration(path string, useDevDotEnv bool) (*Settings, error) {
var environment Environment
if env := os.Getenv("APP_ENVIRONMENT"); env != "" {
environment = Environment(env)
Expand All @@ -66,7 +66,7 @@ func GetConfiguration(path string) (*Settings, error) {
v.AddConfigPath(path)

if environment == EnvironmentLocal {
return readLocal(v, path)
return readLocal(v, path, useDevDotEnv)
} else {
return readProd(v)
}
Expand Down
9 changes: 7 additions & 2 deletions backend/src/config/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/viper"
)

func readLocal(v *viper.Viper, path string) (*Settings, error) {
func readLocal(v *viper.Viper, path string, useDevDotEnv bool) (*Settings, error) {
var intermediateSettings intermediateSettings

env := string(EnvironmentLocal)
Expand All @@ -27,7 +27,12 @@ func readLocal(v *viper.Viper, path string) (*Settings, error) {
return nil, fmt.Errorf("failed to convert intermediate settings into final settings: %w", err)
}

err = godotenv.Load(fmt.Sprintf("%s/.env.template", path))
if useDevDotEnv {
err = godotenv.Load(fmt.Sprintf("%s/.env.dev", path))
} else {
err = godotenv.Load(fmt.Sprintf("%s/.env.template", path))
}

if err != nil {
return nil, fmt.Errorf("failed to load %s/.env.template: %w", path, err)
}
Expand Down
5 changes: 3 additions & 2 deletions backend/src/controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ func (a *AuthController) Logout(c *fiber.Ctx) error {
// @Tags auth
// @Accept json
// @Produce json
// @Param userID path string true "User ID"
// @Param userBody body models.UpdatePasswordRequestBody true "User Body"
// @Success 200 {object} utilities.SuccessResponse
// @Failure 400 {object} errors.Error
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 429 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Failure 429 {object}
// @Router /auth/update-password/:userID [post]
// @Router /auth/update-password/{userID} [post]
func (a *AuthController) UpdatePassword(c *fiber.Ctx) error {
var userBody models.UpdatePasswordRequestBody

Expand Down
12 changes: 6 additions & 6 deletions backend/src/controllers/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewCategoryController(categoryService services.CategoryServiceInterface) *C
// @Failure 401 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/ [post]
// @Router /categories/ [post]
func (cat *CategoryController) CreateCategory(c *fiber.Ctx) error {
var categoryBody models.CategoryRequestBody

Expand Down Expand Up @@ -61,8 +61,8 @@ func (cat *CategoryController) CreateCategory(c *fiber.Ctx) error {
// @Failure 400 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/ [get]
func (cat *CategoryController) GetAllCategories(c *fiber.Ctx) error {
// @Router /categories/ [get]
func (cat *CategoryController) GetCategories(c *fiber.Ctx) error {
defaultLimit := 10
defaultPage := 1

Expand All @@ -86,7 +86,7 @@ func (cat *CategoryController) GetAllCategories(c *fiber.Ctx) error {
// @Failure 400 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/{categoryID} [get]
// @Router /categories/{categoryID}/ [get]
func (cat *CategoryController) GetCategory(c *fiber.Ctx) error {
category, err := cat.categoryService.GetCategory(c.Params("categoryID"))
if err != nil {
Expand All @@ -109,7 +109,7 @@ func (cat *CategoryController) GetCategory(c *fiber.Ctx) error {
// @Failure 401 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/{categoryID} [delete]
// @Router /categories/{categoryID}/ [delete]
func (cat *CategoryController) DeleteCategory(c *fiber.Ctx) error {
if err := cat.categoryService.DeleteCategory(c.Params("categoryID")); err != nil {
return err.FiberError(c)
Expand All @@ -133,7 +133,7 @@ func (cat *CategoryController) DeleteCategory(c *fiber.Ctx) error {
// @Failure 401 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /category/{categoryID} [put]
// @Router /categories/{categoryID}/ [patch]
func (cat *CategoryController) UpdateCategory(c *fiber.Ctx) error {
var category models.CategoryRequestBody

Expand Down
4 changes: 2 additions & 2 deletions backend/src/controllers/category_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewCategoryTagController(categoryTagService services.CategoryTagServiceInte
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /category/{categoryID}/tags [get]
// @Router /categories/{categoryID}/tags/ [get]
func (ct *CategoryTagController) GetTagsByCategory(c *fiber.Ctx) error {
defaultLimit := 10
defaultPage := 1
Expand All @@ -56,7 +56,7 @@ func (ct *CategoryTagController) GetTagsByCategory(c *fiber.Ctx) error {
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /category/{categoryID}/tags/{tagID} [get]
// @Router /categories/{categoryID}/tags/{tagID}/ [get]
func (ct *CategoryTagController) GetTagByCategory(c *fiber.Ctx) error {
tag, err := ct.categoryTagService.GetTagByCategory(c.Params("categoryID"), c.Params("tagID"))
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions backend/src/controllers/club.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewClubController(clubService services.ClubServiceInterface) *ClubControlle
// @Success 200 {object} []models.Club
// @Failure 400 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/ [get]
// @Router /clubs/ [get]
func (cl *ClubController) GetClubs(c *fiber.Ctx) error {
var queryParams models.ClubQueryParams

Expand Down Expand Up @@ -60,7 +60,7 @@ func (cl *ClubController) GetClubs(c *fiber.Ctx) error {
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/ [post]
// @Router /clubs/ [post]
func (cl *ClubController) CreateClub(c *fiber.Ctx) error {
var clubBody models.CreateClubRequestBody
if err := c.BodyParser(&clubBody); err != nil {
Expand All @@ -87,7 +87,7 @@ func (cl *ClubController) CreateClub(c *fiber.Ctx) error {
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID} [get]
// @Router /clubs/{clubID}/ [get]
func (cl *ClubController) GetClub(c *fiber.Ctx) error {
club, err := cl.clubService.GetClub(c.Params("clubID"))
if err != nil {
Expand All @@ -112,7 +112,7 @@ func (cl *ClubController) GetClub(c *fiber.Ctx) error {
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID} [put]
// @Router /clubs/{clubID}/ [patch]
func (cl *ClubController) UpdateClub(c *fiber.Ctx) error {
var clubBody models.UpdateClubRequestBody

Expand Down Expand Up @@ -141,7 +141,7 @@ func (cl *ClubController) UpdateClub(c *fiber.Ctx) error {
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID} [delete]
// @Router /clubs/{clubID}/ [delete]
func (cl *ClubController) DeleteClub(c *fiber.Ctx) error {
err := cl.clubService.DeleteClub(c.Params("clubID"))
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions backend/src/controllers/club_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewClubContactController(clubContactService services.ClubContactServiceInte
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/contacts [get]
// @Router /clubs/{clubID}/contacts/ [get]
func (cc *ClubContactController) GetClubContacts(c *fiber.Ctx) error {
contacts, err := cc.clubContactService.GetClubContacts(c.Params("clubID"))
if err != nil {
Expand All @@ -37,11 +37,11 @@ func (cc *ClubContactController) GetClubContacts(c *fiber.Ctx) error {
return c.Status(fiber.StatusOK).JSON(contacts)
}

// PostContact godoc
// PutContact godoc
//
// @Summary Creates a contact
// @Description Creates a contact
// @ID create-contact
// @ID put-contact
// @Tags club-contact
// @Accept json
// @Produce json
Expand All @@ -52,7 +52,7 @@ func (cc *ClubContactController) GetClubContacts(c *fiber.Ctx) error {
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/contacts [post]
// @Router /clubs/{clubID}/contacts/ [put]
func (cc *ClubContactController) PutContact(c *fiber.Ctx) error {
var contactBody models.PutContactRequestBody

Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/club_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewClubEventController(clubEventService services.ClubEventServiceInterface)
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/events [get]
// @Router /clubs/{clubID}/events/ [get]
func (cl *ClubEventController) GetClubEvents(c *fiber.Ctx) error {
defaultLimit := 10
defaultPage := 1
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/club_follower.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewClubFollowerController(clubFollowerService services.ClubFollowerServiceI
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/followers [get]
// @Router /clubs/{clubID}/followers/ [get]
func (cf *ClubFollowerController) GetClubFollowers(c *fiber.Ctx) error {
defaultLimit := 10
defaultPage := 1
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/club_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewClubMemberController(clubMemberService services.ClubMemberServiceInterfa
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/members [get]
// @Router /clubs/{clubID}/members/ [get]
func (cm *ClubMemberController) GetClubMembers(c *fiber.Ctx) error {
defaultLimit := 10
defaultPage := 1
Expand Down
6 changes: 3 additions & 3 deletions backend/src/controllers/club_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewClubTagController(clubTagService services.ClubTagServiceInterface) *Club
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/tags [post]
// @Router /clubs/{clubID}/tags/ [post]
func (l *ClubTagController) CreateClubTags(c *fiber.Ctx) error {
var clubTagsBody models.CreateClubTagsRequestBody
if err := c.BodyParser(&clubTagsBody); err != nil {
Expand All @@ -57,7 +57,7 @@ func (l *ClubTagController) CreateClubTags(c *fiber.Ctx) error {
// @Failure 400 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/tags [get]
// @Router /clubs/{clubID}/tags/ [get]
func (l *ClubTagController) GetClubTags(c *fiber.Ctx) error {
clubTags, err := l.clubTagService.GetClubTags(c.Params("clubID"))
if err != nil {
Expand All @@ -81,7 +81,7 @@ func (l *ClubTagController) GetClubTags(c *fiber.Ctx) error {
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /club/{clubID}/tags/{tagID} [delete]
// @Router /clubs/{clubID}/tags/{tagID}/ [delete]
func (l *ClubTagController) DeleteClubTag(c *fiber.Ctx) error {
err := l.clubTagService.DeleteClubTag(c.Params("clubID"), c.Params("tagID"))
if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions backend/src/controllers/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ func NewContactController(contactService services.ContactServiceInterface) *Cont
return &ContactController{contactService: contactService}
}

// CreateContact godoc
// GetContact godoc
//
// @Summary Creates a contact
// @Description Creates a contact
// @ID create-contact
// @Summary Retrieves a contact
// @Description Retrieves a contact by id
// @ID get-contact
// @Tags contact
// @Accept json
// @Produce json
// @Param contactBody body models.Contact true "Contact Body"
// @Param contactID path string true "Contact ID"
// @Success 201 {object} models.Contact
// @Failure 400 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /contact/ [post]
// @Router /contacts/{contactID}/ [get]
func (co *ContactController) GetContact(c *fiber.Ctx) error {
contact, err := co.contactService.GetContact(c.Params("contactID"))
if err != nil {
Expand All @@ -51,7 +51,7 @@ func (co *ContactController) GetContact(c *fiber.Ctx) error {
// @Failure 400 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /contact/ [get]
// @Router /contacts/ [get]
func (co *ContactController) GetContacts(c *fiber.Ctx) error {
defaultLimit := 10
defaultPage := 1
Expand All @@ -64,20 +64,20 @@ func (co *ContactController) GetContacts(c *fiber.Ctx) error {
return c.Status(fiber.StatusOK).JSON(contacts)
}

// CreateContact godoc
// DeleteContact godoc
//
// @Summary Creates a contact
// @Description Creates a contact
// @ID create-contact
// @Summary Deletes a contact
// @Description Deletes a contact
// @ID delete-contact
// @Tags contact
// @Accept json
// @Produce json
// @Param contactBody body models.Contact true "Contact Body"
// @Param contactID path string true "Contact ID"
// @Success 201 {object} models.Contact
// @Failure 400 {string} errors.Error
// @Failure 404 {string} errors.Error
// @Failure 500 {string} errors.Error
// @Router /contact/ [post]
// @Router /contacts/{contactID}/ [delete]
func (co *ContactController) DeleteContact(c *fiber.Ctx) error {
err := co.contactService.DeleteContact(c.Params("contactID"))
if err != nil {
Expand Down
Loading

0 comments on commit 346105e

Please sign in to comment.