feat: improved building

This commit is contained in:
2025-04-17 20:30:21 -04:00
parent 7a799868fb
commit 1c7cf7966f
11 changed files with 121 additions and 83 deletions

View File

@ -2,6 +2,7 @@ package database
import (
"embed"
"io"
"log"
"net/url"
@ -9,8 +10,9 @@ import (
_ "github.com/spotdemo4/dbmate-sqlite-modernc/pkg/driver/sqlite" // Modernc sqlite
)
func Migrate(dsn string, dbFS *embed.FS) error {
if dbFS == nil {
func Migrate(dsn string, dbFS embed.FS) error {
_, err := dbFS.ReadDir(".")
if err == io.EOF {
return nil
}
@ -22,6 +24,7 @@ func Migrate(dsn string, dbFS *embed.FS) error {
db := dbmate.New(dburl)
db.Driver()
db.FS = dbFS
db.AutoDumpSchema = false
log.Println("Migrations:")
migrations, err := db.FindMigrations()

View File

@ -2,14 +2,16 @@ package client
import (
"embed"
"io"
"io/fs"
"net/http"
"github.com/spotdemo4/trevstack/server/internal/interceptors"
)
func NewClientHandler(key string, clientFS *embed.FS) http.Handler {
if clientFS == nil {
func NewClientHandler(key string, clientFS embed.FS) http.Handler {
_, err := clientFS.ReadDir(".")
if err == io.EOF {
return http.NotFoundHandler()
}