Files
sonr/cmd/dwn/main.go
T

41 lines
575 B
Go
Raw Normal View History

2024-09-07 18:12:58 -04:00
//go:build js && wasm
// +build js,wasm
package main
import (
"github.com/labstack/echo/v4"
2024-09-11 15:10:54 -04:00
"github.com/onsonr/sonr/internal/vfs/wasm"
2024-09-07 18:12:58 -04:00
"github.com/onsonr/sonr/internal/db"
)
2024-09-11 15:10:54 -04:00
var dwn *DWN
type DWN struct {
*echo.Echo
2024-09-14 12:47:25 -04:00
DB *db.DB
2024-09-11 15:10:54 -04:00
}
2024-09-07 18:12:58 -04:00
func main() {
2024-09-11 15:10:54 -04:00
dwn = initRails()
wasm.Serve(dwn.Echo)
2024-09-07 18:12:58 -04:00
}
2024-09-11 15:10:54 -04:00
// initRails initializes the Rails application
func initRails() *DWN {
// Open the database
2024-09-14 12:47:25 -04:00
e := echo.New()
db, err := db.New()
2024-09-07 18:12:58 -04:00
if err != nil {
panic(err.Error())
}
2024-09-14 12:47:25 -04:00
db.ServeEcho(e.Group("/dwn"))
2024-09-11 15:10:54 -04:00
// Initialize the htmx handler
return &DWN{
2024-09-14 12:47:25 -04:00
Echo: e,
2024-09-11 15:10:54 -04:00
DB: db,
2024-09-07 18:12:58 -04:00
}
}