Skip to content

Commit

Permalink
Merge pull request #37 from tensorplex-labs/staging
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
jarvis8x7b authored Oct 17, 2024
2 parents b44ab79 + 7f44fe4 commit 679baea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func main() {
router := gin.Default()
// read allowedOrigins from environment variable which is a comma separated string
allowedOrigins := strings.Split(utils.LoadDotEnv("CORS_ALLOWED_ORIGINS"), ",")
allowedOrigins = append(allowedOrigins, "http://localhost*")

log.Info().Msgf("Allowed origins: %v", allowedOrigins)
config := cors.Config{
Expand Down
11 changes: 9 additions & 2 deletions pkg/orm/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ package orm

import (
"context"
"dojo-api/db"
"dojo-api/utils"
"encoding/json"
"fmt"
"net/url"
"os"
"runtime"
"strconv"
"sync"
"sync/atomic"
"time"

"dojo-api/db"
"dojo-api/utils"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
Expand Down Expand Up @@ -214,6 +217,10 @@ func buildPostgresConnString(secrets *DbSecrets) string {
dbName := utils.LoadDotEnv("DB_NAME")
safePassword := url.QueryEscape(secrets.password)
databaseUrl := "postgresql://" + secrets.username + ":" + safePassword + "@" + host + "/" + dbName
// add connection pooling etc.
maxConns := runtime.NumCPU()*2 + 1
databaseUrl += "connection_limit=" + strconv.Itoa(maxConns) + "&pool_timeout=20"

// hack this so Prisma can read it directly, handle complexities here
os.Setenv("DATABASE_URL", databaseUrl)
return databaseUrl
Expand Down

0 comments on commit 679baea

Please sign in to comment.