fix: prepared statements not working in prod mode

This commit is contained in:
Vikram Rangnekar
2020-04-19 12:54:37 -04:00
parent a6691de1b7
commit c400461835
7 changed files with 46 additions and 65 deletions

View File

@ -24,10 +24,6 @@ func cmdServ(cmd *cobra.Command, args []string) {
fatalInProd(err, "failed to connect to database")
}
// if conf != nil && db != nil {
// initResolvers()
// }
sg, err = core.NewSuperGraph(&conf.Core, db)
if err != nil {
fatalInProd(err, "failed to initialize Super Graph")

View File

@ -49,10 +49,6 @@ func ReadInConfig(configFile string) (*Config, error) {
return nil, fmt.Errorf("failed to decode config, %v", err)
}
if len(c.Core.AllowListFile) == 0 {
c.Core.AllowListFile = path.Join(cpath, "allow.list")
}
return c, nil
}

View File

@ -8,6 +8,7 @@ import (
"fmt"
"io/ioutil"
"path"
"path/filepath"
"strings"
"time"
@ -21,7 +22,12 @@ const (
)
func initConf() (*Config, error) {
c, err := ReadInConfig(path.Join(confPath, GetConfigName()))
cp, err := filepath.Abs(confPath)
if err != nil {
return nil, err
}
c, err := ReadInConfig(path.Join(cp, GetConfigName()))
if err != nil {
return nil, err
}
@ -86,6 +92,14 @@ func initConf() (*Config, error) {
c.AuthFailBlock = false
}
if len(c.AllowListFile) == 0 {
c.AllowListFile = c.relPath("./allow.list")
}
if c.Production {
c.UseAllowList = true
}
return c, nil
}

View File

@ -190,17 +190,3 @@ func self() (string, error) {
}
return bin, nil
}
// Get path relative to cwd
func relpath(p string) string {
cwd, err := os.Getwd()
if err != nil {
return p
}
if strings.HasPrefix(p, cwd) {
return "./" + strings.TrimLeft(p[len(cwd):], "/")
}
return p
}

View File

@ -119,3 +119,17 @@ func isDev() bool {
func sanitize(value string) string {
return strings.ToLower(strings.TrimSpace(value))
}
// Get path relative to cwd
func relpath(p string) string {
cwd, err := os.Getwd()
if err != nil {
return p
}
if strings.HasPrefix(p, cwd) {
return "./" + strings.TrimLeft(p[len(cwd):], "/")
}
return p
}