diff --git a/backend/src/email/email.go b/backend/src/email/email.go index b2c77ef77..0152e5e02 100644 --- a/backend/src/email/email.go +++ b/backend/src/email/email.go @@ -12,6 +12,8 @@ import ( type EmailServiceInterface interface { SendPasswordResetEmail(name, email, token string) *errors.Error SendEmailVerification(email, code string) *errors.Error + SendWelcomeEmail(name, email string) *errors.Error + SendPasswordChangedEmail(name, email string) *errors.Error } type EmailService struct { @@ -66,6 +68,48 @@ func (e *EmailService) SendEmailVerification(email, code string) *errors.Error { return nil } +func (e *EmailService) SendWelcomeEmail(name, email string) *errors.Error { + template, err := getTemplateString("welcome") + if err != nil { + return &errors.FailedToGetTemplate + } + + params := &resend.SendEmailRequest{ + From: "onboarding@resend.dev", + To: []string{email}, + Subject: "Welcome to Resend", + Html: fmt.Sprintf(*template, name), + } + + _, err = e.Client.Emails.Send(params) + if err != nil { + return &errors.FailedToSendEmail + } + + return nil +} + +func (e *EmailService) SendPasswordChangedEmail(name, email string) *errors.Error { + template, err := getTemplateString("password_change_complete") + if err != nil { + return &errors.FailedToGetTemplate + } + + params := &resend.SendEmailRequest{ + From: "onboarding@resend.dev", + To: []string{email}, + Subject: "Password Changed", + Html: fmt.Sprintf(*template, name), + } + + _, err = e.Client.Emails.Send(params) + if err != nil { + return &errors.FailedToSendEmail + } + + return nil +} + func getTemplateString(name string) (*string, error) { // TODO: use default file location cwd, err := os.Getwd() diff --git a/backend/src/server/routes/auth.go b/backend/src/server/routes/auth.go index b4d19aa6e..6a7f5db2a 100644 --- a/backend/src/server/routes/auth.go +++ b/backend/src/server/routes/auth.go @@ -3,24 +3,22 @@ package routes import ( "time" - "github.com/GenerateNU/sac/backend/src/config" "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func Auth(router fiber.Router, authService services.AuthServiceInterface, settings config.AuthSettings, authMiddleware *middleware.AuthMiddlewareService) { - authController := controllers.NewAuthController(authService, settings) +func Auth(params types.RouteParams) { + authController := controllers.NewAuthController(services.NewAuthService(params.ServiceParams), params.Settings) // api/v1/auth/* - auth := router.Group("/auth") + auth := params.Router.Group("/auth") auth.Post("/login", authController.Login) auth.Get("/logout", authController.Logout) auth.Get("/refresh", authController.Refresh) auth.Get("/me", authController.Me) - auth.Post("/update-password/:userID", authMiddleware.Limiter(2, 1*time.Minute), authMiddleware.UserAuthorizeById, authController.UpdatePassword) + auth.Post("/update-password/:userID", params.AuthMiddleware.Limiter(2, 1*time.Minute), params.AuthMiddleware.UserAuthorizeById, authController.UpdatePassword) auth.Post("/send-code/:userID", authController.SendCode) auth.Post("/verify-email", authController.VerifyEmail) auth.Post("/forgot-password", authController.ForgotPassword) diff --git a/backend/src/server/routes/category.go b/backend/src/server/routes/category.go index fdd37823a..6e80fd36f 100644 --- a/backend/src/server/routes/category.go +++ b/backend/src/server/routes/category.go @@ -3,34 +3,35 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/auth" "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/go-playground/validator/v10" + "github.com/GenerateNU/sac/backend/src/types" "github.com/gofiber/fiber/v2" - "gorm.io/gorm" ) -func CategoryRoutes(router fiber.Router, db *gorm.DB, validate *validator.Validate, authMiddleware *middleware.AuthMiddlewareService) { - categoryIDRoute := Category(router, services.NewCategoryService(db, validate), authMiddleware) +func CategoryRoutes(categoryParams types.RouteParams) { + categoryIDRoute := Category(categoryParams) - CategoryTag(categoryIDRoute, services.NewCategoryTagService(db, validate)) + // update the router in params + categoryParams.Router = categoryIDRoute + + CategoryTag(categoryParams) } -func Category(router fiber.Router, categoryService services.CategoryServiceInterface, authMiddleware *middleware.AuthMiddlewareService) fiber.Router { - categoryController := controllers.NewCategoryController(categoryService) +func Category(categoryParams types.RouteParams) fiber.Router { + categoryController := controllers.NewCategoryController(services.NewCategoryService(categoryParams.ServiceParams)) // api/v1/categories/* - categories := router.Group("/categories") + categories := categoryParams.Router.Group("/categories") - categories.Post("/", authMiddleware.Authorize(auth.CreateAll), categoryController.CreateCategory) + categories.Post("/", categoryParams.AuthMiddleware.Authorize(auth.CreateAll), categoryController.CreateCategory) categories.Get("/", categoryController.GetCategories) // api/v1/categories/:categoryID/* categoriesID := categories.Group("/:categoryID") categoriesID.Get("/", categoryController.GetCategory) - categoriesID.Delete("/", authMiddleware.Authorize(auth.DeleteAll), categoryController.DeleteCategory) - categoriesID.Patch("/", authMiddleware.Authorize(auth.WriteAll), categoryController.UpdateCategory) + categoriesID.Delete("/", categoryParams.AuthMiddleware.Authorize(auth.DeleteAll), categoryController.DeleteCategory) + categoriesID.Patch("/", categoryParams.AuthMiddleware.Authorize(auth.WriteAll), categoryController.UpdateCategory) return categoriesID } diff --git a/backend/src/server/routes/category_tag.go b/backend/src/server/routes/category_tag.go index a29303be0..30f557a6a 100644 --- a/backend/src/server/routes/category_tag.go +++ b/backend/src/server/routes/category_tag.go @@ -3,14 +3,14 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func CategoryTag(categoryIDRoute fiber.Router, categoryTagService services.CategoryTagServiceInterface) { - categoryTagController := controllers.NewCategoryTagController(categoryTagService) +func CategoryTag(categoryParams types.RouteParams) { + categoryTagController := controllers.NewCategoryTagController(services.NewCategoryTagService(categoryParams.ServiceParams)) // api/v1/categories/:categoryID/tags/* - categoryTags := categoryIDRoute.Group("/tags") + categoryTags := categoryParams.Router.Group("/tags") categoryTags.Get("/", categoryTagController.GetTagsByCategory) categoryTags.Get("/:tagID", categoryTagController.GetTagByCategory) diff --git a/backend/src/server/routes/club.go b/backend/src/server/routes/club.go index 68303c378..acd66d877 100644 --- a/backend/src/server/routes/club.go +++ b/backend/src/server/routes/club.go @@ -3,38 +3,39 @@ package routes import ( p "github.com/GenerateNU/sac/backend/src/auth" "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/go-playground/validator/v10" + "github.com/GenerateNU/sac/backend/src/types" "github.com/gofiber/fiber/v2" - "gorm.io/gorm" ) -func ClubRoutes(router fiber.Router, db *gorm.DB, validate *validator.Validate, authMiddleware *middleware.AuthMiddlewareService) { - clubIDRouter := Club(router, services.NewClubService(db, validate), authMiddleware) +func ClubRoutes(clubParams types.RouteParams) { + clubIDRouter := Club(clubParams) - ClubTag(clubIDRouter, services.NewClubTagService(db, validate), authMiddleware) - ClubFollower(clubIDRouter, services.NewClubFollowerService(db), authMiddleware) - ClubMember(clubIDRouter, services.NewClubMemberService(db, validate), authMiddleware) - ClubContact(clubIDRouter, services.NewClubContactService(db, validate), authMiddleware) - ClubEvent(clubIDRouter, services.NewClubEventService(db)) + // update the router in params + clubParams.Router = clubIDRouter + + ClubTag(clubParams) + ClubFollower(clubParams) + ClubMember(clubParams) + ClubContact(clubParams) + ClubEvent(clubParams) } -func Club(router fiber.Router, clubService services.ClubServiceInterface, authMiddleware *middleware.AuthMiddlewareService) fiber.Router { - clubController := controllers.NewClubController(clubService) +func Club(clubParams types.RouteParams) fiber.Router { + clubController := controllers.NewClubController(services.NewClubService(clubParams.ServiceParams)) // api/v1/clubs/* - clubs := router.Group("/clubs") + clubs := clubParams.Router.Group("/clubs") clubs.Get("/", clubController.GetClubs) - clubs.Post("/", authMiddleware.Authorize(p.CreateAll), clubController.CreateClub) + clubs.Post("/", clubParams.AuthMiddleware.Authorize(p.CreateAll), clubController.CreateClub) // api/v1/clubs/:clubID/* clubsID := clubs.Group("/:clubID") clubsID.Get("/", clubController.GetClub) - clubsID.Patch("/", authMiddleware.ClubAuthorizeById, clubController.UpdateClub) - clubsID.Delete("/", authMiddleware.Authorize(p.DeleteAll), clubController.DeleteClub) + clubsID.Patch("/", clubParams.AuthMiddleware.ClubAuthorizeById, clubController.UpdateClub) + clubsID.Delete("/", clubParams.AuthMiddleware.Authorize(p.DeleteAll), clubController.DeleteClub) return clubsID } diff --git a/backend/src/server/routes/club_contact.go b/backend/src/server/routes/club_contact.go index e8d36300b..f4494d9e2 100644 --- a/backend/src/server/routes/club_contact.go +++ b/backend/src/server/routes/club_contact.go @@ -2,17 +2,16 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func ClubContact(clubsIDRouter fiber.Router, clubContactService services.ClubContactServiceInterface, authMiddleware *middleware.AuthMiddlewareService) { - clubContactController := controllers.NewClubContactController(clubContactService) +func ClubContact(clubParams types.RouteParams) { + clubContactController := controllers.NewClubContactController(services.NewClubContactService(clubParams.ServiceParams)) - clubContacts := clubsIDRouter.Group("/contacts") + clubContacts := clubParams.Router.Group("/contacts") // api/v1/clubs/:clubID/contacts/* clubContacts.Get("/", clubContactController.GetClubContacts) - clubContacts.Put("/", authMiddleware.ClubAuthorizeById, clubContactController.PutContact) + clubContacts.Put("/", clubParams.AuthMiddleware.ClubAuthorizeById, clubContactController.PutContact) } diff --git a/backend/src/server/routes/club_event.go b/backend/src/server/routes/club_event.go index 7819174f6..b1e47e0d9 100644 --- a/backend/src/server/routes/club_event.go +++ b/backend/src/server/routes/club_event.go @@ -3,14 +3,14 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func ClubEvent(clubIDRouter fiber.Router, clubEventService services.ClubEventServiceInterface) { - clubEventController := controllers.NewClubEventController(clubEventService) +func ClubEvent(clubParams types.RouteParams) { + clubEventController := controllers.NewClubEventController(services.NewClubEventService(clubParams.ServiceParams)) // api/v1/clubs/:clubID/events/* - events := clubIDRouter.Group("/events") + events := clubParams.Router.Group("/events") events.Get("/", clubEventController.GetClubEvents) } diff --git a/backend/src/server/routes/club_follower.go b/backend/src/server/routes/club_follower.go index 8a1713451..1458d1d6c 100644 --- a/backend/src/server/routes/club_follower.go +++ b/backend/src/server/routes/club_follower.go @@ -2,16 +2,15 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func ClubFollower(clubsIDRouter fiber.Router, clubFollowerService services.ClubFollowerServiceInterface, authMiddleware *middleware.AuthMiddlewareService) { - clubFollowerController := controllers.NewClubFollowerController(clubFollowerService) +func ClubFollower(clubParams types.RouteParams) { + clubFollowerController := controllers.NewClubFollowerController(services.NewClubFollowerService(clubParams.ServiceParams)) - clubFollower := clubsIDRouter.Group("/followers") + clubFollower := clubParams.Router.Group("/followers") // api/clubs/:clubID/followers/* - clubFollower.Get("/", authMiddleware.ClubAuthorizeById, clubFollowerController.GetClubFollowers) + clubFollower.Get("/", clubParams.AuthMiddleware.ClubAuthorizeById, clubFollowerController.GetClubFollowers) } diff --git a/backend/src/server/routes/club_member.go b/backend/src/server/routes/club_member.go index 263519a65..3e11aa432 100644 --- a/backend/src/server/routes/club_member.go +++ b/backend/src/server/routes/club_member.go @@ -2,16 +2,15 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func ClubMember(clubsIDRouter fiber.Router, clubMemberService services.ClubMemberServiceInterface, authMiddleware *middleware.AuthMiddlewareService) { - clubMemberController := controllers.NewClubMemberController(clubMemberService) +func ClubMember(clubParams types.RouteParams) { + clubMemberController := controllers.NewClubMemberController(services.NewClubMemberService(clubParams.ServiceParams)) - clubMember := clubsIDRouter.Group("/members") + clubMember := clubParams.Router.Group("/members") // api/v1/clubs/:clubID/members/* - clubMember.Get("/", authMiddleware.ClubAuthorizeById, clubMemberController.GetClubMembers) + clubMember.Get("/", clubParams.AuthMiddleware.ClubAuthorizeById, clubMemberController.GetClubMembers) } diff --git a/backend/src/server/routes/club_tag.go b/backend/src/server/routes/club_tag.go index d8d0e6463..7c4122b53 100644 --- a/backend/src/server/routes/club_tag.go +++ b/backend/src/server/routes/club_tag.go @@ -2,17 +2,16 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func ClubTag(clubIDRouter fiber.Router, clubTagService services.ClubTagServiceInterface, authMiddleware *middleware.AuthMiddlewareService) { - clubTagController := controllers.NewClubTagController(clubTagService) +func ClubTag(clubParams types.RouteParams) { + clubTagController := controllers.NewClubTagController(services.NewClubTagService(clubParams.ServiceParams)) - clubTags := clubIDRouter.Group("/tags") + clubTags := clubParams.Router.Group("/tags") clubTags.Get("/", clubTagController.GetClubTags) - clubTags.Post("/", authMiddleware.ClubAuthorizeById, clubTagController.CreateClubTags) - clubTags.Delete("/:tagID", authMiddleware.ClubAuthorizeById, clubTagController.DeleteClubTag) + clubTags.Post("/", clubParams.AuthMiddleware.ClubAuthorizeById, clubTagController.CreateClubTags) + clubTags.Delete("/:tagID", clubParams.AuthMiddleware.ClubAuthorizeById, clubTagController.DeleteClubTag) } diff --git a/backend/src/server/routes/contact.go b/backend/src/server/routes/contact.go index 56e4969de..142ab920e 100644 --- a/backend/src/server/routes/contact.go +++ b/backend/src/server/routes/contact.go @@ -2,18 +2,17 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func Contact(router fiber.Router, contactService services.ContactServiceInterface, authMiddleware *middleware.AuthMiddlewareService) { - contactController := controllers.NewContactController(contactService) +func Contact(contactParams types.RouteParams) { + contactController := controllers.NewContactController(services.NewContactService(contactParams.ServiceParams)) // api/v1/contacts/* - contacts := router.Group("/contacts") + contacts := contactParams.Router.Group("/contacts") contacts.Get("/", contactController.GetContacts) contacts.Get("/:contactID", contactController.GetContact) - contacts.Delete("/:contactID", authMiddleware.UserAuthorizeById, contactController.DeleteContact) + contacts.Delete("/:contactID", contactParams.AuthMiddleware.UserAuthorizeById, contactController.DeleteContact) } diff --git a/backend/src/server/routes/event.go b/backend/src/server/routes/event.go index 0d6495370..cac6947b3 100644 --- a/backend/src/server/routes/event.go +++ b/backend/src/server/routes/event.go @@ -2,28 +2,27 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func Event(router fiber.Router, eventService services.EventServiceInterface, authMiddleware *middleware.AuthMiddlewareService) { - eventController := controllers.NewEventController(eventService) +func Event(eventParams types.RouteParams) { + eventController := controllers.NewEventController(services.NewEventService(eventParams.ServiceParams)) // api/v1/events/* - events := router.Group("/events") + events := eventParams.Router.Group("/events") events.Get("/", eventController.GetAllEvents) - events.Post("/", authMiddleware.ClubAuthorizeById, eventController.CreateEvent) + events.Post("/", eventParams.AuthMiddleware.ClubAuthorizeById, eventController.CreateEvent) // api/v1/events/:eventID/* eventID := events.Group("/:eventID") eventID.Get("/", eventController.GetEvent) eventID.Get("/series", eventController.GetSeriesByEventID) - events.Patch("/", authMiddleware.ClubAuthorizeById, eventController.UpdateEvent) - eventID.Delete("/", authMiddleware.ClubAuthorizeById, eventController.DeleteEvent) - eventID.Delete("/series", authMiddleware.ClubAuthorizeById, eventController.DeleteSeriesByEventID) + events.Patch("/", eventParams.AuthMiddleware.ClubAuthorizeById, eventController.UpdateEvent) + eventID.Delete("/", eventParams.AuthMiddleware.ClubAuthorizeById, eventController.DeleteEvent) + eventID.Delete("/series", eventParams.AuthMiddleware.ClubAuthorizeById, eventController.DeleteSeriesByEventID) // api/v1/events/:eventID/series/* series := events.Group("/series") @@ -38,6 +37,6 @@ func Event(router fiber.Router, eventService services.EventServiceInterface, aut seriesID := series.Group("/:seriesID") seriesID.Get("/", eventController.GetSeriesByID) - seriesID.Patch("/", authMiddleware.ClubAuthorizeById, eventController.UpdateSeriesByID) - seriesID.Delete("/", authMiddleware.ClubAuthorizeById, eventController.DeleteSeriesByID) + seriesID.Patch("/", eventParams.AuthMiddleware.ClubAuthorizeById, eventController.UpdateSeriesByID) + seriesID.Delete("/", eventParams.AuthMiddleware.ClubAuthorizeById, eventController.DeleteSeriesByID) } diff --git a/backend/src/server/routes/tag.go b/backend/src/server/routes/tag.go index 47d15cfb8..9d5c35695 100644 --- a/backend/src/server/routes/tag.go +++ b/backend/src/server/routes/tag.go @@ -3,19 +3,18 @@ package routes import ( p "github.com/GenerateNU/sac/backend/src/auth" "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func Tag(router fiber.Router, tagService services.TagServiceInterface, authMiddleware *middleware.AuthMiddlewareService) { - tagController := controllers.NewTagController(tagService) +func Tag(tagParams types.RouteParams) { + tagController := controllers.NewTagController(services.NewTagService(tagParams.ServiceParams)) - tags := router.Group("/tags") + tags := tagParams.Router.Group("/tags") tags.Get("/", tagController.GetTags) tags.Get("/:tagID", tagController.GetTag) - tags.Post("/", authMiddleware.Authorize(p.CreateAll), tagController.CreateTag) - tags.Patch("/:tagID", authMiddleware.Authorize(p.WriteAll), tagController.UpdateTag) - tags.Delete("/:tagID", authMiddleware.Authorize(p.DeleteAll), tagController.DeleteTag) + tags.Post("/", tagParams.AuthMiddleware.Authorize(p.CreateAll), tagController.CreateTag) + tags.Patch("/:tagID", tagParams.AuthMiddleware.Authorize(p.WriteAll), tagController.UpdateTag) + tags.Delete("/:tagID", tagParams.AuthMiddleware.Authorize(p.DeleteAll), tagController.DeleteTag) } diff --git a/backend/src/server/routes/user.go b/backend/src/server/routes/user.go index 1cea2b693..e668b62a4 100644 --- a/backend/src/server/routes/user.go +++ b/backend/src/server/routes/user.go @@ -3,33 +3,34 @@ package routes import ( p "github.com/GenerateNU/sac/backend/src/auth" "github.com/GenerateNU/sac/backend/src/controllers" - "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/services" - "github.com/go-playground/validator/v10" + "github.com/GenerateNU/sac/backend/src/types" "github.com/gofiber/fiber/v2" - "gorm.io/gorm" ) -func UserRoutes(router fiber.Router, db *gorm.DB, validate *validator.Validate, authMiddleware *middleware.AuthMiddlewareService) { - usersRouter := User(router, services.NewUserService(db, validate), authMiddleware) +func UserRoutes(userParams types.RouteParams) { + usersRouter := User(userParams) - UserTag(usersRouter, services.NewUserTagService(db, validate)) - UserFollower(usersRouter, services.NewUserFollowerService(db, validate)) - UserMember(usersRouter, services.NewUserMemberService(db)) + // update the router in params + userParams.Router = usersRouter + + UserTag(userParams) + UserFollower(userParams) + UserMember(userParams) } -func User(router fiber.Router, userService services.UserServiceInterface, authMiddleware *middleware.AuthMiddlewareService) fiber.Router { - userController := controllers.NewUserController(userService) +func User(userParams types.RouteParams) fiber.Router { + userController := controllers.NewUserController(services.NewUserService(userParams.ServiceParams)) // api/v1/users/* - users := router.Group("/users") + users := userParams.Router.Group("/users") users.Post("/", userController.CreateUser) - users.Get("/", authMiddleware.Authorize(p.ReadAll), userController.GetUsers) + users.Get("/", userParams.AuthMiddleware.Authorize(p.ReadAll), userController.GetUsers) // api/v1/users/:userID/* usersID := users.Group("/:userID") - usersID.Use(authMiddleware.UserAuthorizeById) + usersID.Use(userParams.AuthMiddleware.UserAuthorizeById) usersID.Get("/", userController.GetUser) usersID.Patch("/", userController.UpdateUser) diff --git a/backend/src/server/routes/user_follower.go b/backend/src/server/routes/user_follower.go index 574f8cbcb..24773a9fb 100644 --- a/backend/src/server/routes/user_follower.go +++ b/backend/src/server/routes/user_follower.go @@ -3,14 +3,14 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func UserFollower(userRouter fiber.Router, userFollowerService services.UserFollowerServiceInterface) { - userFollowerController := controllers.NewUserFollowerController(userFollowerService) +func UserFollower(userParams types.RouteParams) { + userFollowerController := controllers.NewUserFollowerController(services.NewUserFollowerService(userParams.ServiceParams)) // api/v1/users/:userID/follower/* - userFollower := userRouter.Group("/follower") + userFollower := userParams.Router.Group("/follower") userFollower.Get("/", userFollowerController.GetFollowing) userFollower.Post("/:clubID", userFollowerController.CreateFollowing) diff --git a/backend/src/server/routes/user_member.go b/backend/src/server/routes/user_member.go index d65af5c9d..290ca8bf1 100644 --- a/backend/src/server/routes/user_member.go +++ b/backend/src/server/routes/user_member.go @@ -3,14 +3,14 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func UserMember(usersRouter fiber.Router, userMembershipService services.UserMemberServiceInterface) { - userMemberController := controllers.NewUserMemberController(userMembershipService) +func UserMember(userParams types.RouteParams) { + userMemberController := controllers.NewUserMemberController(services.NewUserMemberService(userParams.ServiceParams)) // api/v1/users/:userID/member/* - userMember := usersRouter.Group("/member") + userMember := userParams.Router.Group("/member") userMember.Get("/", userMemberController.GetMembership) userMember.Post("/:clubID", userMemberController.CreateMembership) diff --git a/backend/src/server/routes/user_tag.go b/backend/src/server/routes/user_tag.go index e2f83380b..d0a7e7452 100644 --- a/backend/src/server/routes/user_tag.go +++ b/backend/src/server/routes/user_tag.go @@ -3,14 +3,14 @@ package routes import ( "github.com/GenerateNU/sac/backend/src/controllers" "github.com/GenerateNU/sac/backend/src/services" - "github.com/gofiber/fiber/v2" + "github.com/GenerateNU/sac/backend/src/types" ) -func UserTag(usersRouter fiber.Router, userTagService services.UserTagServiceInterface) { - userTagController := controllers.NewUserTagController(userTagService) +func UserTag(userParams types.RouteParams) { + userTagController := controllers.NewUserTagController(services.NewUserTagService(userParams.ServiceParams)) // api/v1/user/:userID/tags/* - userTags := usersRouter.Group("/tags") + userTags := userParams.Router.Group("/tags") userTags.Post("/", userTagController.CreateUserTags) userTags.Get("/", userTagController.GetUserTags) diff --git a/backend/src/server/server.go b/backend/src/server/server.go index 797796801..b6735d748 100644 --- a/backend/src/server/server.go +++ b/backend/src/server/server.go @@ -1,16 +1,15 @@ package server import ( + "encoding/json" "fmt" "github.com/GenerateNU/sac/backend/src/config" "github.com/GenerateNU/sac/backend/src/email" "github.com/GenerateNU/sac/backend/src/middleware" "github.com/GenerateNU/sac/backend/src/server/routes" - "github.com/GenerateNU/sac/backend/src/services" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/goccy/go-json" - "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" "github.com/gofiber/fiber/v2/middleware/logger" @@ -41,14 +40,25 @@ func Init(db *gorm.DB, settings config.Settings) *fiber.App { apiv1 := app.Group("/api/v1") apiv1.Use(authMiddleware.Authenticate) + routeParams := types.RouteParams{ + Router: apiv1, + Settings: settings.Auth, + AuthMiddleware: authMiddleware, + ServiceParams: types.ServiceParams{ + DB: db, + Validate: validate, + Email: emailService, + }, + } + routes.Utility(app) - routes.Auth(apiv1, services.NewAuthService(db, validate, emailService), settings.Auth, authMiddleware) - routes.UserRoutes(apiv1, db, validate, authMiddleware) - routes.Contact(apiv1, services.NewContactService(db, validate), authMiddleware) - routes.ClubRoutes(apiv1, db, validate, authMiddleware) - routes.Tag(apiv1, services.NewTagService(db, validate), authMiddleware) - routes.CategoryRoutes(apiv1, db, validate, authMiddleware) - routes.Event(apiv1, services.NewEventService(db, validate), authMiddleware) + routes.Auth(routeParams) + routes.UserRoutes(routeParams) + routes.Contact(routeParams) + routes.ClubRoutes(routeParams) + routes.Tag(routeParams) + routes.CategoryRoutes(routeParams) + routes.Event(routeParams) return app } diff --git a/backend/src/services/auth.go b/backend/src/services/auth.go index df3788dbd..b209a379b 100644 --- a/backend/src/services/auth.go +++ b/backend/src/services/auth.go @@ -4,13 +4,11 @@ import ( "time" "github.com/GenerateNU/sac/backend/src/auth" - "github.com/GenerateNU/sac/backend/src/email" "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type AuthServiceInterface interface { @@ -25,17 +23,11 @@ type AuthServiceInterface interface { } type AuthService struct { - DB *gorm.DB - Validate *validator.Validate - Email *email.EmailService + types.ServiceParams } -func NewAuthService(db *gorm.DB, validate *validator.Validate, email *email.EmailService) *AuthService { - return &AuthService{ - DB: db, - Validate: validate, - Email: email, - } +func NewAuthService(serviceParams types.ServiceParams) *AuthService { + return &AuthService{serviceParams} } func (a *AuthService) Me(id string) (*models.User, *errors.Error) { diff --git a/backend/src/services/category.go b/backend/src/services/category.go index ead4df2c0..33f1cf6c9 100644 --- a/backend/src/services/category.go +++ b/backend/src/services/category.go @@ -4,14 +4,11 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "golang.org/x/text/cases" "golang.org/x/text/language" - - "gorm.io/gorm" ) type CategoryServiceInterface interface { @@ -23,12 +20,11 @@ type CategoryServiceInterface interface { } type CategoryService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewCategoryService(db *gorm.DB, validate *validator.Validate) *CategoryService { - return &CategoryService{DB: db, Validate: validate} +func NewCategoryService(params types.ServiceParams) *CategoryService { + return &CategoryService{params} } func (c *CategoryService) CreateCategory(categoryBody models.CategoryRequestBody) (*models.Category, *errors.Error) { diff --git a/backend/src/services/category_tag.go b/backend/src/services/category_tag.go index a16286687..a91fb0daf 100644 --- a/backend/src/services/category_tag.go +++ b/backend/src/services/category_tag.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type CategoryTagServiceInterface interface { @@ -15,12 +14,11 @@ type CategoryTagServiceInterface interface { } type CategoryTagService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewCategoryTagService(db *gorm.DB, validate *validator.Validate) *CategoryTagService { - return &CategoryTagService{DB: db, Validate: validate} +func NewCategoryTagService(params types.ServiceParams) *CategoryTagService { + return &CategoryTagService{params} } func (t *CategoryTagService) GetTagsByCategory(categoryID string, limit string, page string) ([]models.Tag, *errors.Error) { diff --git a/backend/src/services/club.go b/backend/src/services/club.go index ff2c56669..d7b48618b 100644 --- a/backend/src/services/club.go +++ b/backend/src/services/club.go @@ -4,10 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - - "gorm.io/gorm" ) type ClubServiceInterface interface { @@ -19,12 +17,11 @@ type ClubServiceInterface interface { } type ClubService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewClubService(db *gorm.DB, validate *validator.Validate) *ClubService { - return &ClubService{DB: db, Validate: validate} +func NewClubService(params types.ServiceParams) *ClubService { + return &ClubService{params} } func (c *ClubService) GetClubs(queryParams *models.ClubQueryParams) ([]models.Club, *errors.Error) { diff --git a/backend/src/services/club_contact.go b/backend/src/services/club_contact.go index b39bf471b..72abb949d 100644 --- a/backend/src/services/club_contact.go +++ b/backend/src/services/club_contact.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type ClubContactServiceInterface interface { @@ -15,12 +14,11 @@ type ClubContactServiceInterface interface { } type ClubContactService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewClubContactService(db *gorm.DB, validate *validator.Validate) *ClubContactService { - return &ClubContactService{DB: db, Validate: validate} +func NewClubContactService(params types.ServiceParams) *ClubContactService { + return &ClubContactService{params} } func (c *ClubContactService) GetClubContacts(clubID string) ([]models.Contact, *errors.Error) { diff --git a/backend/src/services/club_event.go b/backend/src/services/club_event.go index c95eadc2a..245a084b9 100644 --- a/backend/src/services/club_event.go +++ b/backend/src/services/club_event.go @@ -4,8 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "gorm.io/gorm" ) type ClubEventServiceInterface interface { @@ -13,11 +13,11 @@ type ClubEventServiceInterface interface { } type ClubEventService struct { - DB *gorm.DB + types.ServiceParams } -func NewClubEventService(db *gorm.DB) *ClubEventService { - return &ClubEventService{DB: db} +func NewClubEventService(params types.ServiceParams) *ClubEventService { + return &ClubEventService{params} } func (c *ClubEventService) GetClubEvents(clubID string, limit string, page string) ([]models.Event, *errors.Error) { diff --git a/backend/src/services/club_follower.go b/backend/src/services/club_follower.go index aaf910f9e..b24abe54a 100644 --- a/backend/src/services/club_follower.go +++ b/backend/src/services/club_follower.go @@ -4,8 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "gorm.io/gorm" ) type ClubFollowerServiceInterface interface { @@ -13,11 +13,11 @@ type ClubFollowerServiceInterface interface { } type ClubFollowerService struct { - DB *gorm.DB + types.ServiceParams } -func NewClubFollowerService(db *gorm.DB) *ClubFollowerService { - return &ClubFollowerService{DB: db} +func NewClubFollowerService(params types.ServiceParams) *ClubFollowerService { + return &ClubFollowerService{params} } func (cf *ClubFollowerService) GetClubFollowers(clubID string, limit string, page string) ([]models.User, *errors.Error) { diff --git a/backend/src/services/club_member.go b/backend/src/services/club_member.go index cbc2452ec..9e55cdbf9 100644 --- a/backend/src/services/club_member.go +++ b/backend/src/services/club_member.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type ClubMemberServiceInterface interface { @@ -14,11 +13,11 @@ type ClubMemberServiceInterface interface { } type ClubMemberService struct { - DB *gorm.DB + types.ServiceParams } -func NewClubMemberService(db *gorm.DB, validate *validator.Validate) *ClubMemberService { - return &ClubMemberService{DB: db} +func NewClubMemberService(params types.ServiceParams) *ClubMemberService { + return &ClubMemberService{params} } func (cms *ClubMemberService) GetClubMembers(clubID string, limit string, page string) ([]models.User, *errors.Error) { diff --git a/backend/src/services/club_tag.go b/backend/src/services/club_tag.go index c1ff23d87..dcdafb109 100644 --- a/backend/src/services/club_tag.go +++ b/backend/src/services/club_tag.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type ClubTagServiceInterface interface { @@ -16,12 +15,11 @@ type ClubTagServiceInterface interface { } type ClubTagService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewClubTagService(db *gorm.DB, validate *validator.Validate) ClubTagServiceInterface { - return &ClubTagService{DB: db, Validate: validate} +func NewClubTagService(params types.ServiceParams) ClubTagServiceInterface { + return &ClubTagService{params} } func (c *ClubTagService) CreateClubTags(id string, clubTagsBody models.CreateClubTagsRequestBody) ([]models.Tag, *errors.Error) { diff --git a/backend/src/services/contact.go b/backend/src/services/contact.go index 1d04ea695..419133a00 100644 --- a/backend/src/services/contact.go +++ b/backend/src/services/contact.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type ContactServiceInterface interface { @@ -16,12 +15,11 @@ type ContactServiceInterface interface { } type ContactService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewContactService(db *gorm.DB, validate *validator.Validate) *ContactService { - return &ContactService{DB: db, Validate: validate} +func NewContactService(params types.ServiceParams) ContactServiceInterface { + return &ContactService{params} } func (c *ContactService) GetContacts(limit string, page string) ([]models.Contact, *errors.Error) { diff --git a/backend/src/services/event.go b/backend/src/services/event.go index 20834274f..64bd4cdb8 100644 --- a/backend/src/services/event.go +++ b/backend/src/services/event.go @@ -4,10 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - - "gorm.io/gorm" ) type EventServiceInterface interface { @@ -24,12 +22,11 @@ type EventServiceInterface interface { } type EventService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewEventService(db *gorm.DB, validate *validator.Validate) *EventService { - return &EventService{DB: db, Validate: validate} +func NewEventService(params types.ServiceParams) *EventService { + return &EventService{params} } func (e *EventService) GetEvents(limit string, page string) ([]models.Event, *errors.Error) { diff --git a/backend/src/services/tag.go b/backend/src/services/tag.go index 39abbc0e3..bc4c2b639 100644 --- a/backend/src/services/tag.go +++ b/backend/src/services/tag.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type TagServiceInterface interface { @@ -18,12 +17,11 @@ type TagServiceInterface interface { } type TagService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewTagService(db *gorm.DB, validate *validator.Validate) *TagService { - return &TagService{DB: db, Validate: validate} +func NewTagService(params types.ServiceParams) *TagService { + return &TagService{params} } func (t *TagService) CreateTag(tagBody models.CreateTagRequestBody) (*models.Tag, *errors.Error) { diff --git a/backend/src/services/user.go b/backend/src/services/user.go index 579a935ed..42f49536c 100644 --- a/backend/src/services/user.go +++ b/backend/src/services/user.go @@ -7,10 +7,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type UserServiceInterface interface { @@ -22,12 +20,11 @@ type UserServiceInterface interface { } type UserService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewUserService(db *gorm.DB, validate *validator.Validate) *UserService { - return &UserService{DB: db, Validate: validate} +func NewUserService(serviceParams types.ServiceParams) *UserService { + return &UserService{serviceParams} } func (u *UserService) CreateUser(userBody models.CreateUserRequestBody) (*models.User, *errors.Error) { @@ -48,6 +45,9 @@ func (u *UserService) CreateUser(userBody models.CreateUserRequestBody) (*models user.Email = strings.ToLower(userBody.Email) user.PasswordHash = *passwordHash + // send email creation event to email service + // email.SendWelcomeEmail(user.Name, user.Email) + return transactions.CreateUser(u.DB, user) } diff --git a/backend/src/services/user_follower.go b/backend/src/services/user_follower.go index aea27ab2f..956069fb6 100644 --- a/backend/src/services/user_follower.go +++ b/backend/src/services/user_follower.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type UserFollowerServiceInterface interface { @@ -16,12 +15,11 @@ type UserFollowerServiceInterface interface { } type UserFollowerService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewUserFollowerService(db *gorm.DB, validate *validator.Validate) *UserFollowerService { - return &UserFollowerService{DB: db, Validate: validate} +func NewUserFollowerService(params types.ServiceParams) UserFollowerServiceInterface { + return &UserFollowerService{params} } func (u *UserFollowerService) CreateFollowing(userId string, clubId string) *errors.Error { diff --git a/backend/src/services/user_member.go b/backend/src/services/user_member.go index 87a828f92..54e952f0c 100644 --- a/backend/src/services/user_member.go +++ b/backend/src/services/user_member.go @@ -4,8 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "gorm.io/gorm" ) type UserMemberServiceInterface interface { @@ -15,11 +15,11 @@ type UserMemberServiceInterface interface { } type UserMemberService struct { - DB *gorm.DB + types.ServiceParams } -func NewUserMemberService(db *gorm.DB) *UserMemberService { - return &UserMemberService{DB: db} +func NewUserMemberService(params types.ServiceParams) UserMemberServiceInterface { + return &UserMemberService{params} } func (u *UserMemberService) CreateMembership(userID string, clubID string) *errors.Error { diff --git a/backend/src/services/user_tag.go b/backend/src/services/user_tag.go index 27f979f9d..03b4ae275 100644 --- a/backend/src/services/user_tag.go +++ b/backend/src/services/user_tag.go @@ -4,9 +4,8 @@ import ( "github.com/GenerateNU/sac/backend/src/errors" "github.com/GenerateNU/sac/backend/src/models" "github.com/GenerateNU/sac/backend/src/transactions" + "github.com/GenerateNU/sac/backend/src/types" "github.com/GenerateNU/sac/backend/src/utilities" - "github.com/go-playground/validator/v10" - "gorm.io/gorm" ) type UserTagServiceInterface interface { @@ -15,12 +14,11 @@ type UserTagServiceInterface interface { } type UserTagService struct { - DB *gorm.DB - Validate *validator.Validate + types.ServiceParams } -func NewUserTagService(db *gorm.DB, validate *validator.Validate) *UserTagService { - return &UserTagService{DB: db, Validate: validate} +func NewUserTagService(params types.ServiceParams) UserTagServiceInterface { + return &UserTagService{params} } func (u *UserTagService) GetUserTags(id string) ([]models.Tag, *errors.Error) { diff --git a/backend/src/templates/emails/email_verification.html b/backend/src/templates/emails/email_verification.html index 92158a384..101d9f67b 100644 --- a/backend/src/templates/emails/email_verification.html +++ b/backend/src/templates/emails/email_verification.html @@ -1,72 +1,74 @@ - - + Welcome to Hippo! Verify your Email
-

Welcome to Hippo

-

Thank you for signing up! To unlock the full potential of your account and start enjoying our services, - please verify your email address by typing the following code in the verification page:

+

Welcome to Hippo

+

+ Thank you for signing up! To unlock the full potential of your account + and start enjoying our services, please verify your email address by + typing the following code in the verification page: +

-

%s

+

%s

-

If you didn't create an account with Hippo, please disregard this email.

-

We look forward to having you on board!

-

Sincerely,

-

The Hippo Team

+

+ If you didn't create an account with Hippo, please disregard this email. +

+

We look forward to having you on board!

+

Sincerely,

+

The Hippo Team

- - \ No newline at end of file + diff --git a/backend/src/templates/emails/password_change_complete.html b/backend/src/templates/emails/password_change_complete.html new file mode 100644 index 000000000..dc6173767 --- /dev/null +++ b/backend/src/templates/emails/password_change_complete.html @@ -0,0 +1,74 @@ + + + + + Your Hippo Password Has Been Reset + + + + +
+

Your Password Has Been Reset

+

Hi %s,

+

+ This email confirms that your password for your Hippo account has been + successfully reset. +

+

You can now sign in using your new password:

+ Sign in to Hippo +

+ If you did not request this password reset, please contact our support + team immediately. +

+

Sincerely,

+

The Hippo Team

+
+ + + \ No newline at end of file diff --git a/backend/src/templates/emails/password_reset.html b/backend/src/templates/emails/password_reset.html index 473b07fea..f25d9f159 100644 --- a/backend/src/templates/emails/password_reset.html +++ b/backend/src/templates/emails/password_reset.html @@ -1,71 +1,73 @@ - + - - + Password Reset Email
-

Your Hippo Account Needs a New Key!

-

Hi %s,

-

Looks like you've misplaced the key to your Hippo account! Don't worry, we can help you unlock it in no time. - Just click the button below to choose a new password:

Reset Your Password -

Remember, if you didn't request this change, simply disregard this message and your account remains secure. -

-

See you soon,

-

The Hippo Team

+

Your Hippo Account Needs a New Key!

+

Hi %s,

+

+ Looks like you've misplaced the key to your Hippo account! Don't worry, + we can help you unlock it in no time. Just click the button below to + choose a new password: +

+ Reset Your Password +

+ Remember, if you didn't request this change, simply disregard this + message and your account remains secure. +

+

See you soon,

+

The Hippo Team

- - \ No newline at end of file + diff --git a/backend/src/templates/emails/welcome.html b/backend/src/templates/emails/welcome.html new file mode 100644 index 000000000..deea828e8 --- /dev/null +++ b/backend/src/templates/emails/welcome.html @@ -0,0 +1,84 @@ + + + + + Welcome to [Company Name]! + + + + +
+

Welcome to Hippo %s!

+

+ Thank you for creating an account with us. We're excited to have you on + board! +

+

+ Your account is now active, and you can log in using your email address + and password. +

+

+ [Optional: Add a paragraph highlighting benefits of creating an account, + e.g., access exclusive features, receive updates, etc.] +

+

+ To get started, you can visit our website at + hipponeu.com. +

+

+ If you have any questions or need assistance, please don't hesitate to + contact us at generatesac@gmail.com. +

+

We look forward to seeing you around!

+

Sincerely,

+

The Hippo Team

+
+ + + \ No newline at end of file diff --git a/backend/src/types/server.go b/backend/src/types/server.go new file mode 100644 index 000000000..234a345c7 --- /dev/null +++ b/backend/src/types/server.go @@ -0,0 +1,23 @@ +package types + +import ( + "github.com/GenerateNU/sac/backend/src/config" + "github.com/GenerateNU/sac/backend/src/email" + "github.com/GenerateNU/sac/backend/src/middleware" + "github.com/go-playground/validator/v10" + "github.com/gofiber/fiber/v2" + "gorm.io/gorm" +) + +type RouteParams struct { + Router fiber.Router + Settings config.AuthSettings + AuthMiddleware *middleware.AuthMiddlewareService + ServiceParams ServiceParams +} + +type ServiceParams struct { + DB *gorm.DB + Validate *validator.Validate + Email *email.EmailService +}