authorizer/server/constants/env.go

45 lines
902 B
Go
Raw Normal View History

2021-07-12 18:22:16 +00:00
package constants
import (
"log"
"os"
"github.com/joho/godotenv"
"github.com/yauthdev/yauth/server/enum"
)
var (
DB_TYPE = enum.Postgres
DB_URL = "postgresql://localhost:5432/postgres"
SMTP_HOST = ""
SMTP_PORT = ""
SENDER_EMAIL = ""
SENDER_PASSWORD = ""
JWT_TYPE = ""
JWT_SECRET = ""
FRONTEND_URL = ""
2021-07-14 13:22:00 +00:00
PORT = "8080"
REDIS_URL = ""
2021-07-12 18:22:16 +00:00
)
func init() {
err := godotenv.Load()
if err != nil {
log.Println("Error loading .env file")
}
SMTP_HOST = os.Getenv("SMTP_HOST")
SMTP_PORT = os.Getenv("SMTP_PORT")
SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD")
JWT_SECRET = os.Getenv("JWT_SECRET")
JWT_TYPE = os.Getenv("JWT_TYPE")
FRONTEND_URL = os.Getenv("FRONTEND_URL")
2021-07-14 13:22:00 +00:00
PORT = os.Getenv("PORT")
REDIS_URL = os.Getenv("REDIS_URL")
if JWT_TYPE == "" {
JWT_TYPE = "HS256"
}
2021-07-12 18:22:16 +00:00
}