narasiahli-be/app/module/notifications/notifications.module.go

52 lines
1.4 KiB
Go
Raw Normal View History

2026-01-25 21:23:17 +00:00
package notifications
import (
"narasi-ahli-be/app/module/notifications/controller"
"narasi-ahli-be/app/module/notifications/repository"
"narasi-ahli-be/app/module/notifications/service"
"github.com/gofiber/fiber/v2"
"go.uber.org/fx"
)
// struct of NotificationRouter
type NotificationRouter struct {
App fiber.Router
Controller *controller.Controller
}
// register bulky of Notifications module
var NewNotificationsModule = fx.Options(
// register repository
fx.Provide(repository.NewNotificationsRepository),
// register service
fx.Provide(service.NewNotificationsService),
// register controller
fx.Provide(controller.NewController),
// register router
fx.Provide(NewNotificationRouter),
)
// init NotificationRouter
func NewNotificationRouter(fiber *fiber.App, controller *controller.Controller) *NotificationRouter {
return &NotificationRouter{
App: fiber,
Controller: controller,
}
}
// register routes of Notifications module
func (_i *NotificationRouter) RegisterNotificationRoutes() {
notificationsController := _i.Controller.Notifications
_i.App.Route("/notifications", func(router fiber.Router) {
router.Post("/", notificationsController.Create)
router.Get("/:sentTo", notificationsController.ListBySentTo)
router.Put("/:id/read", notificationsController.MarkRead)
router.Delete("/:id", notificationsController.Delete)
})
}