Refactor JWT auth and remove DB dependency from config
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user