working on auth.
mailer, basic setup with html template and a dev treansport
This commit is contained in:
		| @@ -9,7 +9,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"gitserver.in/patialtech/rano/config/dotenv" | ||||
| 	"gitserver.in/patialtech/rano/pkg/logger" | ||||
| 	"gitserver.in/patialtech/rano/util/logger" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -30,33 +30,35 @@ var ( | ||||
| type ( | ||||
| 	Env    string | ||||
| 	Config struct { | ||||
| 		WebPort   int    `env:"WEB_PORT"` | ||||
| 		WebURL    string `env:"WEB_URL"` | ||||
| 		GraphPort int    `env:"GRAPH_PORT"` | ||||
| 		GrapURL   string `env:"GRAPH_URL"` | ||||
| 		DbURL     string `env:"DB_URL"` | ||||
| 		basePath     string | ||||
| 		WebPort      int    `env:"WEB_PORT"` | ||||
| 		WebURL       string `env:"WEB_URL"` | ||||
| 		GraphPort    int    `env:"GRAPH_PORT"` | ||||
| 		GrapURL      string `env:"GRAPH_URL"` | ||||
| 		DbURL        string `env:"DB_URL"` | ||||
| 		MailerTplDir string `env:"MAILER_TEMPLATES_DIR"` | ||||
| 		MailerFrom   string `env:"MAILER_FROM_ADDRESS"` | ||||
| 	} | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	wd, _ := os.Getwd() | ||||
|  | ||||
| 	// In dev env we run test and other program for diff dir locations under project root, | ||||
| 	// this makes reading env file harder. | ||||
| 	// Let's add a hack to make sure we fallback to root dir in dev env | ||||
| 	var base string | ||||
| 	if AppEnv == EnvDev { | ||||
| 		wd, _ := os.Getwd() | ||||
| 		idx := strings.Index(wd, projDir) | ||||
| 		if idx > -1 { | ||||
| 			wd = filepath.Join(wd[:idx], projDir) | ||||
| 			base = filepath.Join(wd[:idx], projDir) | ||||
| 		} | ||||
| 	} else { | ||||
| 		base, _ = os.Executable() | ||||
| 	} | ||||
|  | ||||
| 	envVar, err := dotenv.Read(wd, fmt.Sprintf(".env.%s", AppEnv)) | ||||
| 	envVar, err := dotenv.Read(base, fmt.Sprintf(".env.%s", AppEnv)) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
|  | ||||
| 	conf = &Config{} | ||||
| 	conf = &Config{basePath: base} | ||||
| 	conf.loadEnv(envVar) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import ( | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"gitserver.in/patialtech/rano/pkg/logger" | ||||
| 	"gitserver.in/patialtech/rano/util/logger" | ||||
| ) | ||||
|  | ||||
| // | ||||
|   | ||||
		Reference in New Issue
	
	Block a user