Refactor JWT auth and remove DB dependency from config

This commit is contained in:
2025-05-17 20:28:18 +03:30
parent f9d896bf72
commit 81adfa1ad9
3 changed files with 21 additions and 29 deletions

View File

@@ -2,21 +2,19 @@ package config
import (
//"CatsOfMastodonBotGo/internal/auth"
"CatsOfMastodonBotGo/internal/database"
//"CatsOfMastodonBotGo/internal/services"
"log"
"os"
"gorm.io/gorm"
)
type config struct {
Db *gorm.DB
// PostService *services.PostService
// Jwt *auth.JwtTokenGenerator
AdminPassword string
Instance string
Tag string
JwtSecret string
JwtIssuer string
JwtAudience string
}
var Config *config
@@ -55,26 +53,16 @@ func Load() *config {
audience = "CatsOfMastodonBotGo"
}
// Setup database
db, err := database.Connect()
if err != nil {
log.Fatal(err)
}
//Setup PostService
// var postService = services.NewPostService(db)
// // Setup Jwt
// var jwt = auth.NewJwtTokenGenerator(secret, issuer, audience)
// Inititlize AppContext
var appContext = &config{
Db: db,
// PostService: postService,
// Jwt: jwt,
AdminPassword: adminPassword,
Instance: instance,
Tag: tag,
JwtSecret: secret,
JwtIssuer: issuer,
JwtAudience: audience,
}
return appContext