fix: adjust from boilerplate to lti project

This commit is contained in:
Hafizh A. Y
2025-09-25 11:08:01 +07:00
parent 10506238ae
commit c136206f2d
36 changed files with 76 additions and 118 deletions
BIN
View File
Binary file not shown.
-42
View File
@@ -1,42 +0,0 @@
package config
import (
"os"
"time"
)
type AuthCfg struct {
Issuer string
JWTSecret string
AccessTTL time.Duration
RefreshTTL time.Duration
RefreshCookieName string
RefreshCookiePath string
}
func LoadAuth() AuthCfg {
return AuthCfg{
JWTSecret: getenv("JWT_SECRET", "dev-secret-change-me"),
AccessTTL: getenvDuration("ACCESS_TTL", 10*time.Minute),
RefreshTTL: getenvDuration("REFRESH_TTL", 30*24*time.Hour),
RefreshCookieName: getenv("REFRESH_COOKIE_NAME", "rt"),
RefreshCookiePath: getenv("REFRESH_COOKIE_PATH", "/api/auth"),
Issuer: getenv("ISSUER", "http://localhost:8080"),
}
}
func getenv(k, def string) string {
if v := os.Getenv(k); v != "" {
return v
}
return def
}
func getenvDuration(k string, def time.Duration) time.Duration {
if v := os.Getenv(k); v != "" {
d, err := time.ParseDuration(v)
if err == nil {
return d
}
}
return def
}
+1 -1
View File
@@ -3,7 +3,7 @@ package config
import (
"fmt"
"github.com/hafizhproject45/Golang-Boilerplate.git/internal/utils"
"gitlab.com/mbugroup/lti-api.git/internal/utils"
"github.com/spf13/viper"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package config
import (
"github.com/hafizhproject45/Golang-Boilerplate.git/internal/utils"
"gitlab.com/mbugroup/lti-api.git/internal/utils"
"github.com/bytedance/sonic"
"github.com/gofiber/fiber/v2"