package route

import (
	"gitlab.com/mbugroup/lti-api.git/internal/common/validation"
	trim "gitlab.com/mbugroup/lti-api.git/internal/middleware/trim"
	"gitlab.com/mbugroup/lti-api.git/internal/modules"

	"github.com/gofiber/fiber/v2"
	"gorm.io/gorm"

	approvals "gitlab.com/mbugroup/lti-api.git/internal/modules/approvals"
	constants "gitlab.com/mbugroup/lti-api.git/internal/modules/constants"
	inventory "gitlab.com/mbugroup/lti-api.git/internal/modules/inventory"
	master "gitlab.com/mbugroup/lti-api.git/internal/modules/master"
	production "gitlab.com/mbugroup/lti-api.git/internal/modules/production"
	ssoModule "gitlab.com/mbugroup/lti-api.git/internal/modules/sso"
	users "gitlab.com/mbugroup/lti-api.git/internal/modules/users"
	// MODULE IMPORTS
)

func Routes(app *fiber.App, db *gorm.DB) {
	validate := validation.Validator()
	api := app.Group("/api")
	api.Use(trim.JSONBody())

	// root modules di sini
	allModules := []modules.Module{
		users.UserModule{},
		master.MasterModule{},
		constants.ConstantModule{},
		inventory.InventoryModule{},
		production.ProductionModule{},
		approvals.ApprovalModule{},
		ssoModule.Module{},
		// MODULE REGISTRY
	}

	// daftarkan root modules
	for _, m := range allModules {
		m.RegisterRoutes(api, db, validate)
	}

}
