feat: implement single binary build and env-based auth
Some checks failed
/ build ushare (push) Has been cancelled
/ clean (push) Has been cancelled

- Unify login page styling with share page
- Add AGENTS.md with build commands and code style guidelines
- Add dev.sh and make.sh for development and production builds
- Implement single binary build with embedded frontend using embed.FS
- Change auth configuration from CLI flag to env variables (USHARE_USERNAME, USHARE_PASSWORD)
- Set default credentials: admin / ushare@123
- Fix static file serving for SPA routes
This commit is contained in:
loveuer
2026-01-17 23:28:21 +08:00
parent 34930a3992
commit 56874b754e
13 changed files with 606 additions and 124 deletions

View File

@@ -2,19 +2,20 @@ package api
import (
"context"
"net"
"net/http"
"github.com/loveuer/nf"
"github.com/loveuer/nf/nft/log"
"github.com/loveuer/nf/nft/tool"
"github.com/loveuer/ushare/internal/handler"
"github.com/loveuer/ushare/internal/opt"
"net"
"net/http"
)
func Start(ctx context.Context) <-chan struct{} {
app := nf.New(nf.Config{BodyLimit: 10 * 1024 * 1024 * 1024})
app.Get("/api/available", func(c *nf.Ctx) error {
app.Get("/api/healthz", func(c *nf.Ctx) error {
return c.SendStatus(http.StatusOK)
})
@@ -33,6 +34,9 @@ func Start(ctx context.Context) <-chan struct{} {
api.Get("/ws", handler.LocalWS())
}
// 静态文件服务 - 作为中间件处理
app.Use(handler.ServeFrontendMiddleware())
ready := make(chan struct{})
ln, err := net.Listen("tcp", opt.Cfg.Address)
if err != nil {