Initial commit of admin panel.

This commit is contained in:
mikestefanello 2025-03-30 14:46:46 -04:00
parent c8db468292
commit 33e98f9a9e
8 changed files with 466 additions and 7 deletions

View file

@ -6,17 +6,21 @@ import (
"fmt"
"log/slog"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"github.com/mikestefanello/backlite"
"github.com/spf13/afero"
entsql "entgo.io/ent/dialect/sql"
"entgo.io/ent/entc"
"entgo.io/ent/entc/gen"
"github.com/labstack/echo/v4"
_ "github.com/mattn/go-sqlite3"
"github.com/mikestefanello/backlite"
"github.com/mikestefanello/pagoda/config"
"github.com/mikestefanello/pagoda/ent"
"github.com/mikestefanello/pagoda/pkg/log"
"github.com/spf13/afero"
// Required by ent.
_ "github.com/mikestefanello/pagoda/ent/runtime"
@ -46,6 +50,9 @@ type Container struct {
// ORM stores a client to the ORM.
ORM *ent.Client
// Graph is the entity graph defined by your Ent schema.
Graph *gen.Graph
// Mail stores an email sending client.
Mail *MailClient
@ -184,6 +191,16 @@ func (c *Container) initORM() {
if err := c.ORM.Schema.Create(context.Background()); err != nil {
panic(err)
}
// Load the graph.
_, b, _, _ := runtime.Caller(0)
d := path.Join(path.Dir(b))
p := filepath.Join(filepath.Dir(d), "../ent/schema")
g, err := entc.LoadGraph(p, &gen.Config{})
if err != nil {
panic(err)
}
c.Graph = g
}
// initAuth initializes the authentication client.

View file

@ -17,4 +17,9 @@ func TestNewContainer(t *testing.T) {
assert.NotNil(t, c.Mail)
assert.NotNil(t, c.Auth)
assert.NotNil(t, c.Tasks)
g := c.Graph
if g == nil {
//c.ORM.User.Create().
}
}