Skip to content

Commit

Permalink
fix(app): set services placeholder (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobamkode authored Aug 24, 2024
1 parent 1201d51 commit 21f40ef
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
run:
run: gen build-css
go run cmd/app/main.go

gen:
Expand All @@ -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
14 changes: 14 additions & 0 deletions internal/admin/dashboard.go
Original file line number Diff line number Diff line change
@@ -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")
}
10 changes: 10 additions & 0 deletions internal/api/ping.go
Original file line number Diff line number Diff line change
@@ -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",
})
}

12 changes: 8 additions & 4 deletions internal/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
4 changes: 2 additions & 2 deletions internal/home/home.go → internal/web/home.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package home
package web

import (
"os"
Expand All @@ -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")
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions views/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1 class="text-3xl font-bold underline">{{.Title}}</h1>
4 changes: 3 additions & 1 deletion views/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
</head>

<body>
{{embed}}
<div class="">
{{embed}}
</div>
</body>

</html>

0 comments on commit 21f40ef

Please sign in to comment.