Skip to content

Commit

Permalink
ft(config): config file optimzed
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantprateek committed Aug 22, 2023
1 parent aae3f1e commit 4c074ad
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,14 @@ import (
"github.com/joho/godotenv"
)

func GetEnv() string {
func GetEnv(ENV_VAR string) string {
err := godotenv.Load()
if err != nil {
log.Fatal("Unable to Load environment variables")
}

OpenAI := os.Getenv("OPENAI_KEY")
if OpenAI == "" {
envVar := os.Getenv(ENV_VAR)
if envVar == "" {
log.Fatal("openai api key is not provided.")
}

return OpenAI
}

func GetCMCKey() string {

err := godotenv.Load()
if err != nil {
log.Fatal("Unable to load CMC API key")
}

cmc_api_key := os.Getenv("CMC_PRO_API_KEY")
if cmc_api_key == "" {
log.Fatal("cmc api key is not provided")
}

return cmc_api_key
}

func GetRapidAPI() string {
err := godotenv.Load()
if err != nil {
log.Fatal("Unable to load rapid API key.")
}

rapidAPIKey := os.Getenv("RAPIDAPI_KEY")
if rapidAPIKey == "" {
log.Fatal("Please provide RAPIDAPI key to .env")
}
return rapidAPIKey
return envVar
}

0 comments on commit 4c074ad

Please sign in to comment.