Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions backend/cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log"
"strconv"

Expand All @@ -17,6 +18,9 @@ func main() {
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
fmt.Printf("Loaded Config:\nClient ID: %s\n",
cfg.Cognito.AppClientId,
)

router := setupRouter(cfg)

Expand Down Expand Up @@ -44,15 +48,19 @@ func setupRouter(cfg *config.Config) *gin.Engine {
router.OPTIONS("/*path", func(c *gin.Context) {
c.Status(204)
})
router.GET("/", func(c *gin.Context) {
log.Println("Root route hit")
c.JSON(200, gin.H{"message": "Welcome to ArgueHub API!"})
})

router.POST("/signup", routes.SignUpRouteHandler)
router.POST("/verifyEmail", routes.VerifyEmailRouteHandler)
router.POST("/login", routes.LoginRouteHandler)
router.POST("/forgotPassword", routes.ForgotPasswordRouteHandler)
router.POST("/confirmForgotPassword", routes.VerifyForgotPasswordRouteHandler)
router.POST("/verifyToken", routes.VerifyTokenRouteHandler)

router.GET("/ws", websocket.WebsocketHandler)

return router
}
}
51 changes: 26 additions & 25 deletions backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@ package config

import (
"fmt"
"io/ioutil"
"io/ioutil"

"gopkg.in/yaml.v3"
"gopkg.in/yaml.v3"
)

type Config struct {
Server struct {
Port int `yaml:"port"`
} `yaml:"server"`

Cognito struct {
AppClientId string `yaml:"appClientId"`
AppClientSecret string `yaml:"appClientSecret"`
UserPoolId string `yaml:"userPoolId"`
Region string `yaml:"region"`
} `yaml:"cognito"`

Openai struct {
GptApiKey string `yaml:"gptApiKey"`
} `yaml:"openai`
Server struct {
Port int `yaml:"port"`
} `yaml:"server"`

Cognito struct {
AppClientId string `yaml:"appClientId"`
AppClientSecret string `yaml:"appClientSecret"`
UserPoolId string `yaml:"userPoolId"`
Region string `yaml:"region"`
} `yaml:"cognito"`

Openai struct {
GptApiKey string `yaml:"gptApiKey"`
} `yaml:"openai`
}

func LoadConfig(path string) (*Config, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read config file: %w", err)
}
data, err := ioutil.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read config file: %w", err)
}

var cfg Config
if err := yaml.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("failed to unmarshal yaml: %w", err)
}
var cfg Config
if err := yaml.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("failed to unmarshal yaml: %w", err)
}

return &cfg, nil
return &cfg, nil
}
10 changes: 5 additions & 5 deletions backend/config/config.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ server:
port: 1313

cognito:
appClientId:
appClientSecret:
userPoolId:
region:
appClientId: 7hmap5ff4al6ma60rhmnohs3cp #551qeukcut5prntepn9l595c43
appClientSecret: 1n6jofn700ad1dgv1orrq8semfjpsd2iebg2ai2mmhlpk72tp381 #1ro4h1bes6eq4j19siujahc2s2o0sb1hatj1frreql0anq4k2tr4
userPoolId: eu-north-1_O3svahfGa #eu-north-1_epOMhW4Eu
region: eu-north-1

openai:
gptApiKey:
gptApiKey: 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

Loading