From 10d70d90345fb506b74d4642b9aa056f83e79526 Mon Sep 17 00:00:00 2001 From: Arpit Bhayani Date: Tue, 10 Dec 2024 15:01:14 +0530 Subject: [PATCH] Getting rid of IsTestEnv --- config/config.go | 6 +++--- util/helpers.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index f361dcd..8d60822 100644 --- a/config/config.go +++ b/config/config.go @@ -28,7 +28,7 @@ type Config struct { } Server struct { Port string // Field for the server port - IsTestEnv bool + Environment string RequestLimitPerMin int64 // Field for the request limit RequestWindowSec float64 // Field for the time window in float64 AllowedOrigins []string // Field for the allowed origins @@ -64,14 +64,14 @@ func LoadConfig() *Config { }, Server: struct { Port string - IsTestEnv bool + Environment string RequestLimitPerMin int64 RequestWindowSec float64 AllowedOrigins []string CronCleanupFrequency time.Duration }{ Port: getEnv("PORT", ":8080"), - IsTestEnv: getEnv("ENVIRONMENT", "local") != "production", // Default server port + Environment: getEnv("ENVIRONMENT", "local"), RequestLimitPerMin: getEnvInt("REQUEST_LIMIT_PER_MIN", 1000), // Default request limit RequestWindowSec: getEnvFloat64("REQUEST_WINDOW_SEC", 60), // Default request window in float64 AllowedOrigins: getEnvArray("ALLOWED_ORIGINS", []string{"http://localhost:3000"}), // Default allowed origins diff --git a/util/helpers.go b/util/helpers.go index 0e9854f..323e1ef 100644 --- a/util/helpers.go +++ b/util/helpers.go @@ -55,7 +55,7 @@ func ParseHTTPRequest(r *http.Request) (*cmds.CommandRequest, error) { configValue := config.LoadConfig() // Check if the command is blocklisted - if err := BlockListedCommand(command); err != nil && !configValue.Server.IsTestEnv { + if err := BlockListedCommand(command); err != nil && configValue.Server.Environment == "production" { return nil, err }