init: Initial commit

This commit is contained in:
Björn Benouarets
2026-01-20 06:53:05 +01:00
commit fc8238759a
31 changed files with 1384 additions and 0 deletions

72
app/config/config.go Normal file
View File

@@ -0,0 +1,72 @@
package config
import (
"strings"
"git.secnex.io/secnex/taro-bot/utils"
)
type Config struct {
Debug bool
FiberShowStartupMessage bool
CorsAllowOrigins string
CorsAllowHeaders string
CorsAllowMethods string
Address string
DatabaseHost string
DatabasePort string
DatabaseUser string
DatabasePassword string
DatabaseName string
RedisHost string
RedisPort string
RedisPassword string
JwtSecret string
ENV string
UnprotectedEndpoints []string
MicrosoftTeamsBotUrl string
MicrosoftTenantId string
MicrosoftAppId string
MicrosoftAppSecret string
}
var CONFIG *Config
func generateSecret() string {
return utils.GenerateRandomString(32)
}
func NewConfig() *Config {
ENV := utils.GetEnv("ENV", "development")
UNPROTECTED_ENDPOINTS := strings.Split(utils.GetEnv("UNPROTECTED_ENDPOINTS", ""), ",")
if ENV == "development" {
UNPROTECTED_ENDPOINTS = append(UNPROTECTED_ENDPOINTS, "/api_keys")
}
c := &Config{
Debug: utils.GetEnvBool("DEBUG", false),
FiberShowStartupMessage: utils.GetEnvBool("FIBER_SHOW_STARTUP_MESSAGE", false),
CorsAllowOrigins: utils.GetEnv("CORS_ALLOW_ORIGINS", "*"),
CorsAllowHeaders: utils.GetEnv("CORS_ALLOW_HEADERS", "Origin, Content-Type, Accept"),
CorsAllowMethods: utils.GetEnv("CORS_ALLOW_METHODS", "GET, POST, PUT, DELETE"),
Address: utils.GetEnv("ADDRESS", ":3000"),
DatabaseHost: utils.GetEnv("DATABASE_HOST", "localhost"),
DatabasePort: utils.GetEnv("DATABASE_PORT", "5432"),
DatabaseUser: utils.GetEnv("DATABASE_USER", "postgres"),
DatabasePassword: utils.GetEnv("DATABASE_PASSWORD", "postgres"),
DatabaseName: utils.GetEnv("DATABASE_NAME", "secnex"),
JwtSecret: utils.GetEnv("JWT_SECRET", "your-256-bit-secret"),
RedisHost: utils.GetEnv("REDIS_HOST", "localhost"),
RedisPort: utils.GetEnv("REDIS_PORT", "6379"),
RedisPassword: utils.GetEnv("REDIS_PASSWORD", ""),
ENV: ENV,
UnprotectedEndpoints: UNPROTECTED_ENDPOINTS,
MicrosoftTeamsBotUrl: utils.GetEnv("MICROSOFT_TEAMS_BOT_URL", "https://smba.trafficmanager.net/emea"),
MicrosoftTenantId: utils.GetEnv("MICROSOFT_TENANT_ID", ""),
MicrosoftAppId: utils.GetEnv("MICROSOFT_APP_ID", ""),
MicrosoftAppSecret: utils.GetEnv("MICROSOFT_APP_SECRET", ""),
}
CONFIG = c
return c
}