diff --git a/Makefile b/Makefile index 5d21b44..5fa5f30 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -run: +run: gen build-css go run cmd/app/main.go gen: @@ -18,5 +18,5 @@ migrate-up: migrate-down: go run cmd/migrate/main.go -run=down -build-tailwind: +build-css: npx tailwindcss -i ./assets/css/src.css -o ./assets/css/dist.css diff --git a/internal/admin/dashboard.go b/internal/admin/dashboard.go new file mode 100644 index 0000000..f37b9db --- /dev/null +++ b/internal/admin/dashboard.go @@ -0,0 +1,14 @@ +package admin + +import ( + "os" + + "github.com/gofiber/fiber/v2" +) + +func DashboardPage(c *fiber.Ctx) error { + return c.Render("dashboard", fiber.Map{ + "AppName": os.Getenv("APP_NAME"), + "Title": "Hello, Dashboard!", + }, "layouts/main") +} diff --git a/internal/api/ping.go b/internal/api/ping.go new file mode 100644 index 0000000..bffa9b7 --- /dev/null +++ b/internal/api/ping.go @@ -0,0 +1,10 @@ +package api + +import "github.com/gofiber/fiber/v2" + +func Ping(c *fiber.Ctx) error { + return c.Status(fiber.StatusOK).JSON(fiber.Map{ + "message": "PONG", + }) +} + diff --git a/internal/routes/routes.go b/internal/routes/routes.go index c2ec574..2d4d437 100644 --- a/internal/routes/routes.go +++ b/internal/routes/routes.go @@ -3,7 +3,9 @@ package routes import ( "github.com/gofiber/fiber/v2" "github.com/jackc/pgx/v5/pgxpool" - "github.com/kobamkode/terigu/internal/home" + "github.com/kobamkode/terigu/internal/admin" + "github.com/kobamkode/terigu/internal/api" + "github.com/kobamkode/terigu/internal/web" ) type handler struct { @@ -16,14 +18,16 @@ func NewHandler(app *fiber.App, pool *pgxpool.Pool) *handler { } func (h *handler) Web() { - h.app.Get("/", home.HomePage) + h.app.Get("/", web.HomePage) } func (h *handler) API() { - _ = h.app.Group("/api") + r := h.app.Group("/api") + r.Get("/ping", api.Ping) } func (h *handler) Admin() { - _ = h.app.Group("/admin") + r := h.app.Group("/admin") + r.Get("/", admin.DashboardPage) } diff --git a/internal/home/home.go b/internal/web/home.go similarity index 77% rename from internal/home/home.go rename to internal/web/home.go index 6f07adc..d86be39 100644 --- a/internal/home/home.go +++ b/internal/web/home.go @@ -1,4 +1,4 @@ -package home +package web import ( "os" @@ -7,7 +7,7 @@ import ( ) func HomePage(c *fiber.Ctx) error { - return c.Render("index", fiber.Map{ + return c.Render("home", fiber.Map{ "AppName": os.Getenv("APP_NAME"), "Title": "Hello, World!", }, "layouts/main") diff --git a/views/index.html b/views/dashboard.html similarity index 100% rename from views/index.html rename to views/dashboard.html diff --git a/views/home.html b/views/home.html new file mode 100644 index 0000000..7240d2d --- /dev/null +++ b/views/home.html @@ -0,0 +1 @@ +