feat: migrations

This commit is contained in:
2025-04-10 19:15:21 -04:00
parent 1667b78a0a
commit f9772bce47
35 changed files with 1144 additions and 370 deletions

View File

@ -1,17 +1,23 @@
package client
import (
"embed"
"io/fs"
"net/http"
"github.com/spotdemo4/trevstack/server/internal/interceptors"
)
var embedfs *http.FileSystem
func NewClientHandler(key string) http.Handler {
if embedfs != nil {
return interceptors.WithAuthRedirect(http.FileServer(*embedfs), key)
func NewClientHandler(key string, clientFS *embed.FS) http.Handler {
if clientFS == nil {
return http.NotFoundHandler()
}
return http.NotFoundHandler()
client, err := fs.Sub(clientFS, "client")
if err != nil {
return http.NotFoundHandler()
}
fs := http.FS(client)
return interceptors.WithAuthRedirect(http.FileServer(fs), key)
}

View File

@ -1,24 +0,0 @@
//go:build !dev
package client
import (
"embed"
"io/fs"
"log"
"net/http"
)
//go:embed all:client
var eclient embed.FS
func init() {
log.Println("Initializing client for production")
client, err := fs.Sub(eclient, "client")
if err != nil {
log.Fatalf("failed to get client: %v", err)
}
fs := http.FS(client)
embedfs = &fs
}