cleanup(admin): This large-scale refactoring effort involves cleaning up redundant logic and standardizing database interactions across several modules.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gin-contrib/gzip"
|
||||
@@ -9,14 +8,11 @@ import (
|
||||
|
||||
"warpbox/lib/boxstore"
|
||||
"warpbox/lib/config"
|
||||
"warpbox/lib/metastore"
|
||||
"warpbox/lib/routing"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
config *config.Config
|
||||
store *metastore.Store
|
||||
adminLoginEnabled bool
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
func Run(addr string) error {
|
||||
@@ -30,31 +26,7 @@ func Run(addr string) error {
|
||||
|
||||
applyBoxstoreRuntimeConfig(cfg)
|
||||
|
||||
store, err := metastore.Open(cfg.DBDir)
|
||||
if err != nil {
|
||||
return fmt.Errorf("open metadata database: %w", err)
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
overrides, err := store.ListSettings()
|
||||
if err != nil {
|
||||
return fmt.Errorf("load settings overrides: %w", err)
|
||||
}
|
||||
if err := cfg.ApplyOverrides(overrides); err != nil {
|
||||
return fmt.Errorf("apply settings overrides: %w", err)
|
||||
}
|
||||
applyBoxstoreRuntimeConfig(cfg)
|
||||
|
||||
bootstrap, err := metastore.BootstrapAdmin(cfg, store)
|
||||
if err != nil {
|
||||
return fmt.Errorf("bootstrap admin metadata: %w", err)
|
||||
}
|
||||
|
||||
app := &App{
|
||||
config: cfg,
|
||||
store: store,
|
||||
adminLoginEnabled: bootstrap.AdminLoginEnabled,
|
||||
}
|
||||
app := &App{config: cfg}
|
||||
|
||||
router := gin.Default()
|
||||
router.LoadHTMLGlob("templates/*.html")
|
||||
@@ -74,7 +46,6 @@ func Run(addr string) error {
|
||||
DirectBoxUpload: app.handleDirectBoxUpload,
|
||||
LegacyUpload: app.handleLegacyUpload,
|
||||
})
|
||||
app.registerAdminRoutes(router)
|
||||
|
||||
compressed := router.Group("/", gzip.Gzip(gzip.DefaultCompression))
|
||||
compressed.Static("/static", "./static")
|
||||
|
||||
Reference in New Issue
Block a user