-
Notifications
You must be signed in to change notification settings - Fork 160
fix: Resolve backend compilation errors and structural conflicts #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
90afc31
580e7f6
70cd342
1d95d35
7ed5128
7f00c93
abd4477
c0477e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ package config | |
|
|
||
| import ( | ||
| "fmt" | ||
| "io/ioutil" | ||
| "os" | ||
|
|
||
| "gopkg.in/yaml.v3" | ||
| ) | ||
|
|
@@ -40,29 +40,26 @@ type Config struct { | |
| JWT struct { | ||
| Secret string `yaml:"secret"` | ||
| Expiry int `yaml:"expiry"` | ||
| } | ||
| } `yaml:"jwt"` | ||
|
|
||
| SMTP struct { | ||
| Host string `yaml:"host"` | ||
| Port int `yaml:"port"` | ||
| Username string `yaml:"username"` // Gmail address | ||
| Password string `yaml:"password"` // App Password | ||
| SenderEmail string `yaml:"senderEmail"` // Same as Username for Gmail | ||
| SenderName string `yaml:"senderName"` | ||
| } `yaml:"smtp"` | ||
|
Comment on lines
+45
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential scope creep and security concern. The SMTP configuration block appears to add new functionality rather than fix the compilation errors described in PR #128. Consider whether this belongs in a separate feature PR. Additionally, storing the SMTP password in plain text in the YAML file poses a security risk. Consider using environment variables or a secrets manager for sensitive credentials. Example using environment variables: SMTP struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Username string `yaml:"username"`
Password string // Load from environment variable instead
SenderEmail string `yaml:"senderEmail"`
SenderName string `yaml:"senderName"`
} `yaml:"smtp"`Then in your initialization code, load the password from an environment variable: cfg.SMTP.Password = os.Getenv("SMTP_PASSWORD")🤖 Prompt for AI Agents |
||
|
|
||
| SMTP struct { // Add SMTP configuration | ||
| Host string | ||
| Port int | ||
| Username string // Gmail address | ||
| Password string // App Password | ||
| SenderEmail string // Same as Username for Gmail | ||
| SenderName string | ||
| } | ||
| GoogleOAuth struct { | ||
| ClientID string `yaml:"clientID"` | ||
| } | ||
| Redis struct { | ||
| URL string `yaml:"url"` | ||
| Password string `yaml:"password"` | ||
| DB int `yaml:"db"` | ||
| } | ||
| } `yaml:"googleOAuth"` | ||
| } | ||
|
|
||
| // LoadConfig reads the configuration file | ||
| func LoadConfig(path string) (*Config, error) { | ||
| data, err := ioutil.ReadFile(path) | ||
|
|
||
| data, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to read config file: %w", err) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| server: | ||
| port: 1313 # The port number your backend server will run on | ||
|
|
||
| database: | ||
| uri: "mongodb+srv://<username>:<password>@<cluster-url>/<database-name>" | ||
| # Replace with your MongoDB Atlas connection string | ||
| # Get this from your MongoDB Atlas dashboard after creating a cluster and database | ||
|
|
||
| gemini: | ||
| apiKey: "<YOUR_GEMINI_API_KEY>" | ||
| # API key for OpenAI / Gemini model access | ||
| # Obtain from your OpenRouter.ai or OpenAI account dashboard | ||
|
|
||
| jwt: | ||
| secret: "<YOUR_JWT_SECRET>" | ||
| # A secret string used to sign JWT tokens | ||
| # Generate a strong random string (e.g. use `openssl rand -hex 32`) | ||
|
|
||
| expiry: 1440 | ||
| # Token expiry time in minutes (e.g. 1440 = 24 hours) | ||
|
|
||
| smtp: | ||
| host: "smtp.gmail.com" | ||
| # SMTP server host for sending emails (example is Gmail SMTP) | ||
|
|
||
| port: 587 | ||
| # SMTP server port (587 for TLS) | ||
|
|
||
| username: "<YOUR_EMAIL_ADDRESS>" | ||
| # Email username (your email address) | ||
|
|
||
| password: "<YOUR_EMAIL_PASSWORD_OR_APP_PASSWORD>" | ||
| # Password for the email or app-specific password if 2FA is enabled | ||
|
|
||
| senderEmail: "<YOUR_EMAIL_ADDRESS>" | ||
| # The 'from' email address used when sending mails | ||
|
|
||
| senderName: "DebateAI Team" | ||
|
|
||
| googleOAuth: | ||
| clientID: "<YOUR_GOOGLE_OAUTH_CLIENT_ID>" | ||
| # Google OAuth Client ID for OAuth login | ||
| # Obtain from Google Cloud Console (APIs & Services > Credentials > OAuth 2.0 Client IDs) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code: unreachable default assignment.
The inner check
if redisURL == ""on line 48 is unreachable because line 46 already ensurescfg.Redis.Addr != "", and line 47 assigns that non-empty value toredisURL. The default"localhost:6379"will never be applied.Apply this diff to remove the dead code:
if cfg.Redis.Addr != "" { redisURL := cfg.Redis.Addr - if redisURL == "" { - redisURL = "localhost:6379" - } if err := debate.InitRedis(redisURL, cfg.Redis.Password, cfg.Redis.DB); err != nil {Alternatively, if a default Redis address is desired, restructure the logic:
📝 Committable suggestion
🤖 Prompt for AI Agents