Skip to content

Commit

Permalink
Getting rid of IsTestEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitbbhayani committed Dec 10, 2024
1 parent e448d78 commit 10d70d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion util/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 10d70d9

Please sign in to comment.