2024-09-19 23:13:04 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2024-09-23 03:46:54 +00:00
|
|
|
"embed"
|
2024-09-19 23:13:04 +00:00
|
|
|
"github.com/maddalax/htmgo/framework/h"
|
2024-09-23 01:59:44 +00:00
|
|
|
"github.com/maddalax/htmgo/framework/service"
|
2024-09-19 23:13:04 +00:00
|
|
|
_ "github.com/mattn/go-sqlite3"
|
2024-09-23 03:46:54 +00:00
|
|
|
"io/fs"
|
2024-09-26 19:39:34 +00:00
|
|
|
"net/http"
|
2024-09-23 02:15:53 +00:00
|
|
|
"todolist/__htmgo"
|
2024-09-19 23:13:04 +00:00
|
|
|
"todolist/ent"
|
|
|
|
|
"todolist/infrastructure/db"
|
|
|
|
|
)
|
|
|
|
|
|
2024-09-23 03:46:54 +00:00
|
|
|
//go:embed assets/dist/*
|
|
|
|
|
var StaticAssets embed.FS
|
|
|
|
|
|
2024-09-19 23:13:04 +00:00
|
|
|
func main() {
|
|
|
|
|
locator := service.NewLocator()
|
|
|
|
|
|
|
|
|
|
service.Set[ent.Client](locator, service.Singleton, func() *ent.Client {
|
|
|
|
|
return db.Provide()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
h.Start(h.AppOpts{
|
|
|
|
|
ServiceLocator: locator,
|
|
|
|
|
LiveReload: true,
|
2024-09-26 19:39:34 +00:00
|
|
|
Register: func(app *h.App) {
|
|
|
|
|
|
|
|
|
|
sub, err := fs.Sub(StaticAssets, "assets/dist")
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
http.FileServerFS(sub)
|
|
|
|
|
|
|
|
|
|
app.Router.Handle("/public/*", http.StripPrefix("/public", http.FileServerFS(sub)))
|
|
|
|
|
|
|
|
|
|
__htmgo.Register(app.Router)
|
2024-09-19 23:13:04 +00:00
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|