Skip to content

Commit 4a20e90

Browse files
authored
more cleanup (#138)
* tidy * ui test * screenshots * embed web ui files
1 parent 66b1b88 commit 4a20e90

File tree

12 files changed

+36
-1248
lines changed

12 files changed

+36
-1248
lines changed

.github/workflows/lint.go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permissions:
66
pull-requests: read
77
jobs:
88
golangci:
9-
name: golangci-lint
9+
name: Go
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ permissions:
77
contents: write
88
jobs:
99
goreleaser:
10+
name: Go Release
1011
runs-on: ubuntu-latest
1112
steps:
1213
- name: Checkout

.github/workflows/test.go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Go Tests
1+
name: Go Test
22
on:
33
pull_request:
44
jobs:

.github/workflows/docker.ui.yml .github/workflows/ui.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
name: Docker UI
1+
name: Web UI
22
on:
33
pull_request:
44
jobs:
55
test:
6+
name: Web UI Test
67
runs-on: ubuntu-latest
78
steps:
89
- name: Checkout repository
910
uses: actions/checkout@v4
1011

11-
- name: Build Docker container
12-
run: docker build -t ui-app .
13-
14-
- name: Start Docker container
12+
- name: Start Server
1513
env:
1614
HOST: 0.0.0.0
1715
PORT: 8000
1816
run: |
19-
docker run -d -e HOST -e PORT -p 8000:8000 --name ui ui-app
20-
sleep 5
17+
make run &
18+
19+
- name: Wait for server to start
20+
run: |
21+
while ! curl -s http://localhost:8000 > /dev/null 2>&1; do
22+
sleep 1
23+
done
2124
2225
- uses: actions/setup-node@v4
2326
with:
2427
node-version: lts/*
25-
26-
- name: Debug
27-
run: curl -v http://localhost:8000
2828

2929
- name: Setup npm
3030
run: npm init -y

cmd/reaper/main.go

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package main
22

33
import (
4+
"embed"
45
"fmt"
56
"log"
67
"log/slog"
8+
"net/http"
79
"os"
810
"strings"
911
"time"
1012

1113
"github.com/gofiber/contrib/websocket"
1214
"github.com/gofiber/fiber/v2"
1315
"github.com/gofiber/fiber/v2/middleware/cors"
16+
"github.com/gofiber/fiber/v2/middleware/filesystem"
1417
"github.com/gofiber/fiber/v2/middleware/recover"
1518

1619
"github.com/ghostsecurity/reaper/internal/database"
@@ -19,6 +22,9 @@ import (
1922
"github.com/ghostsecurity/reaper/internal/middleware"
2023
)
2124

25+
//go:embed dist/*
26+
var static embed.FS
27+
2228
func main() {
2329
// We don't need the time field in the local logs
2430
opts := slog.HandlerOptions{
@@ -114,15 +120,17 @@ func main() {
114120
// settings
115121

116122
// serve static frontend files
117-
app.Static("/", "./dist")
118-
119-
// if 404, serve index.html
120-
app.Use(func(c *fiber.Ctx) error {
121-
if c.Method() != fiber.MethodGet {
122-
return c.SendStatus(fiber.StatusNotFound)
123-
}
124-
return c.SendFile("./dist/index.html")
125-
})
123+
app.Use("/", filesystem.New(filesystem.Config{
124+
Root: http.FS(static),
125+
PathPrefix: "dist",
126+
Browse: true,
127+
NotFoundFile: "dist/index.html",
128+
}))
129+
app.Use("/assets", filesystem.New(filesystem.Config{
130+
Root: http.FS(static),
131+
PathPrefix: "dist/assets",
132+
Browse: true,
133+
}))
126134

127135
// Start server
128136
host := os.Getenv("HOST")

docs/screens/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
![reaper-01.png](reaper-01.png)
2+
![reaper-02.png](reaper-02.png)
3+
![reaper-03.png](reaper-03.png)
4+
![reaper-04.png](reaper-04.png)

docs/screens/reaper-01.png

887 KB
Loading

docs/screens/reaper-02.png

1.22 MB
Loading

docs/screens/reaper-03.png

1 MB
Loading

docs/screens/reaper-04.png

1.19 MB
Loading

0 commit comments

Comments
 (0)