From f8f10b7c15d64b248dd9ad4b7dceb4e45b245c8e Mon Sep 17 00:00:00 2001 From: drainpilled Date: Sun, 20 Oct 2024 05:12:54 -0400 Subject: [PATCH] tmp --- cmd/main.go | 6 +++++- docker-compose.yaml | 4 ++-- internal/app/app.go | 9 +++++++-- internal/storage/models/auth.go | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index cc17ef1..b7ab511 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -5,6 +5,7 @@ import ( "git.optclblast.xyz/draincloud/draincloud-core/internal/app" "git.optclblast.xyz/draincloud/draincloud-core/internal/plugin" + "git.optclblast.xyz/draincloud/draincloud-core/internal/storage/postgres" ) func main() { @@ -12,5 +13,8 @@ func main() { ps := plugin.NewPluginStore() pl := plugin.MustNewPluginLoader(ctx, 8081, ps) pl.Run(ctx) - app.New().Run(context.TODO()) + + pg := postgres.New(ctx, "postgres://draincloud:draincloud_secret@localhost:5432/draincloud?sslmode=disable") + + app.New(pg).Run(context.TODO()) } diff --git a/docker-compose.yaml b/docker-compose.yaml index d7ef5e2..d926488 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,9 +7,9 @@ services: environment: POSTGRES_USERNAME: draincloud POSTGRES_DB: draincloud - POSTGRES_PASSWORD: draincloud.dev.secret + POSTGRES_PASSWORD: draincloud_secret volumes: - - draincloud-db-data:/ + - draincloud-db-data:/var/lib/postgresql/data volumes: draincloud-db-data: {} \ No newline at end of file diff --git a/internal/app/app.go b/internal/app/app.go index e44ec3c..7e98211 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -20,11 +20,16 @@ type DrainCloud struct { datadase storage.Database } -func New() *DrainCloud { +func New( + datadase storage.Database, +) *DrainCloud { mux := gin.Default() - d := new(DrainCloud) + d := &DrainCloud{ + datadase: datadase, + } + // Built-in auth component of DrainCloud-Core authGroup := mux.Group("/auth") { authGroup.POST("/register", d.Register) diff --git a/internal/storage/models/auth.go b/internal/storage/models/auth.go index ae0c0d1..38327b3 100644 --- a/internal/storage/models/auth.go +++ b/internal/storage/models/auth.go @@ -4,7 +4,7 @@ import "time" type Session struct { ID string - User *User + User *User } type User struct {