chore: improve project structure

This commit is contained in:
pommee
2025-05-02 08:16:09 +02:00
parent 6d1cbd0c36
commit 8ce754d0a1
110 changed files with 71 additions and 4118 deletions

View File

@@ -17,10 +17,9 @@ exclude_dir = [
"assets",
"tmp",
"vendor",
"website/dist",
"website/node_modules",
"client/dist",
"client/node_modules",
"test",
"testing",
"resources",
]
include_ext = ["go", "tpl", "tmpl", "html", "css", "js", "jsx", "ts", "tsx"]

6
.gitignore vendored
View File

@@ -28,7 +28,7 @@ dist-ssr
*.sln
*.sw?
website/pnpm-lock.yaml
testing/benchmark.new
testing/benchmark.old
client/pnpm-lock.yaml
test/benchmark.new
test/benchmark.old
benchmark.prof

View File

@@ -16,34 +16,34 @@ publish:
docker buildx rm multiarch-builder
build:
pnpm -C website install && pnpm -C website build
pnpm -C client install && pnpm -C client build
start:
docker compose up -d
lint:
pnpm -C website lint && \
pnpm -C client lint && \
golangci-lint run
format:
npx prettier --write "website/**/*.{html,css,js,tsx}"
npx prettier --write "client/**/*.{html,css,js,tsx}"
example-queries:
@./testing/dig-domains.sh
@./test/dig-domains.sh
dev-website:
pnpm -C website install && pnpm -C website dev
pnpm -C client install && pnpm -C client dev
dev-server:
mkdir website/dist ; touch website/dist/.fake
mkdir client/dist ; touch client/dist/.fake
air .
test:
go test -count=1 -bench=. -benchmem ./test/...
bench:
go run testing/benchmark.go -test.bench=.
go run test/benchmark.go -test.bench=.
bench-profile:
go run testing/benchmark.go -test.bench=. & \
go run test/benchmark.go -test.bench=. & \
go tool pprof http://localhost:6060/debug/pprof/profile\?seconds\=5

View File

@@ -5,10 +5,10 @@ import (
"embed"
"encoding/base64"
"fmt"
"goaway/internal/logging"
"goaway/internal/server"
"goaway/internal/settings"
"goaway/internal/user"
"goaway/backend/api/user"
"goaway/backend/dns/server"
"goaway/backend/logging"
"goaway/backend/settings"
"net"
"os"
"time"

View File

@@ -1,7 +1,7 @@
package api
import (
"goaway/internal/user"
"goaway/backend/api/user"
"net/http"
"strings"
"time"

View File

@@ -6,12 +6,12 @@ import (
"encoding/json"
"errors"
"fmt"
"goaway/internal/api/models"
"goaway/internal/database"
"goaway/internal/server"
"goaway/internal/settings"
"goaway/internal/updater"
"goaway/internal/user"
"goaway/backend/api/models"
"goaway/backend/api/user"
"goaway/backend/dns/database"
"goaway/backend/dns/server"
"goaway/backend/settings"
"goaway/backend/updater"
"io"
"io/fs"
"mime"
@@ -40,11 +40,11 @@ func (api *API) ServeEmbeddedContent(content embed.FS) {
return
}
err = fs.WalkDir(content, "website/dist", func(path string, d fs.DirEntry, err error) error {
err = fs.WalkDir(content, "client/dist", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return fmt.Errorf("error walking through path %s: %w", path, err)
}
if d.IsDir() || path == "website/dist/index.html" {
if d.IsDir() || path == "client/dist/index.html" {
return nil
}
@@ -59,7 +59,7 @@ func (api *API) ServeEmbeddedContent(content embed.FS) {
mimeType = "application/octet-stream"
}
route := strings.TrimPrefix(path, "website/dist/")
route := strings.TrimPrefix(path, "client/dist/")
api.router.GET("/"+route, func(c *gin.Context) {
c.Data(http.StatusOK, mimeType, fileContent)
})
@@ -71,7 +71,7 @@ func (api *API) ServeEmbeddedContent(content embed.FS) {
return
}
indexContent, err := content.ReadFile("website/dist/index.html")
indexContent, err := content.ReadFile("client/dist/index.html")
if err != nil {
log.Error("Error reading index.html: %v", err)
return

View File

@@ -3,7 +3,7 @@ package user
import (
"database/sql"
"errors"
"goaway/internal/logging"
"goaway/backend/logging"
"golang.org/x/crypto/bcrypt"
)

View File

@@ -2,7 +2,7 @@ package asciiart
import (
"fmt"
"goaway/internal/settings"
"goaway/backend/settings"
)
const (

View File

@@ -7,7 +7,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"goaway/internal/logging"
"goaway/backend/logging"
"io"
"net/http"
"sort"

View File

@@ -3,10 +3,10 @@ package database
import (
"database/sql"
"fmt"
"goaway/internal/api/models"
dbModel "goaway/internal/database/models"
"goaway/internal/logging"
model "goaway/internal/server/models"
"goaway/backend/api/models"
dbModel "goaway/backend/dns/database/models"
model "goaway/backend/dns/server/models"
"goaway/backend/logging"
"strings"
"time"
)

View File

@@ -3,7 +3,7 @@ package database
import (
"database/sql"
"fmt"
"goaway/internal/database/models"
"goaway/backend/dns/database/models"
"strings"
)

View File

@@ -2,9 +2,9 @@ package server
import (
"fmt"
"goaway/internal/arp"
"goaway/internal/database"
model "goaway/internal/server/models"
arp "goaway/backend/dns"
"goaway/backend/dns/database"
model "goaway/backend/dns/server/models"
"net"
"os"
"strconv"

View File

@@ -2,8 +2,8 @@ package server
import (
"encoding/json"
"goaway/internal/database"
model "goaway/internal/server/models"
"goaway/backend/dns/database"
model "goaway/backend/dns/server/models"
"time"
"github.com/gorilla/websocket"

View File

@@ -3,11 +3,11 @@ package server
import (
"database/sql"
"fmt"
"goaway/internal/blacklist"
"goaway/internal/database"
"goaway/internal/logging"
model "goaway/internal/server/models"
"goaway/internal/settings"
"goaway/backend/dns/blacklist"
"goaway/backend/dns/database"
model "goaway/backend/dns/server/models"
"goaway/backend/logging"
"goaway/backend/settings"
"sync"
"time"

View File

@@ -3,7 +3,7 @@ package settings
import (
"encoding/json"
"fmt"
"goaway/internal/logging"
"goaway/backend/logging"
"io"
"net"
"net/http"

View File

@@ -1,8 +1,8 @@
package setup
import (
"goaway/internal/logging"
"goaway/internal/settings"
"goaway/backend/logging"
"goaway/backend/settings"
"os"
"github.com/Masterminds/semver"

View File

@@ -18,4 +18,4 @@
"hooks": "@/hooks"
},
"iconLibrary": "phosphor-icons/react"
}
}

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -185,10 +185,10 @@ export function Settings() {
return (
<div
className="container mx-auto px-4 py-8 space-y-6
w-full
md:w-4/5
lg:w-3/4
className="container mx-auto px-4 py-8 space-y-6
w-full
md:w-4/5
lg:w-3/4
xl:w-1/2"
>
{SETTINGS_SECTIONS.map(({ title, description, settings }) => (
@@ -203,10 +203,10 @@ export function Settings() {
({ label, key, explanation, options, widgetType: Widget }) => (
<div
key={key}
className="flex flex-col md:flex-row
justify-between
items-start md:items-center
space-y-2 md:space-y-0
className="flex flex-col md:flex-row
justify-between
items-start md:items-center
space-y-2 md:space-y-0
md:space-x-4"
>
<div className="flex-grow">

Some files were not shown because too many files have changed in this diff Show More