replace os.Getenv with envutil.GetenvString
This commit is contained in:
parent
89ce683e08
commit
804264375a
|
@ -31,7 +31,7 @@ type Config struct {
|
|||
|
||||
func Attach(group *gin.RouterGroup, cfg Config) error {
|
||||
if cfg.Resolver == nil {
|
||||
return errors.New("Graphql resolver cannot be nil")
|
||||
return errors.New("cfg.Resolver is required")
|
||||
}
|
||||
gqlHandler := graphqlHandler(prepareConfig(cfg.Resolver, cfg.Directive))
|
||||
group.GET(graphqlEndpoint, gqlHandler)
|
||||
|
|
|
@ -2,8 +2,6 @@ package postgres
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/zdam-egzamin-zawodowy/backend/pkg/util/envutil"
|
||||
|
||||
|
@ -46,10 +44,10 @@ func Connect(cfg *Config) (*pg.DB, error) {
|
|||
|
||||
func prepareOptions() *pg.Options {
|
||||
return &pg.Options{
|
||||
User: os.Getenv("DB_USER"),
|
||||
Password: os.Getenv("DB_PASSWORD"),
|
||||
Database: os.Getenv("DB_NAME"),
|
||||
Addr: os.Getenv("DB_HOST") + ":" + os.Getenv("DB_PORT"),
|
||||
User: envutil.GetenvString("DB_USER"),
|
||||
Password: envutil.GetenvString("DB_PASSWORD"),
|
||||
Database: envutil.GetenvString("DB_NAME"),
|
||||
Addr: envutil.GetenvString("DB_HOST") + ":" + envutil.GetenvString("DB_PORT"),
|
||||
PoolSize: envutil.GetenvInt("DB_POOL_SIZE"),
|
||||
}
|
||||
}
|
||||
|
|
4
main.go
4
main.go
|
@ -48,7 +48,7 @@ func init() {
|
|||
|
||||
func main() {
|
||||
fileStorage := fstorage.New(&fstorage.Config{
|
||||
BasePath: os.Getenv("FILE_STORAGE_PATH"),
|
||||
BasePath: envutil.GetenvString("FILE_STORAGE_PATH"),
|
||||
})
|
||||
|
||||
dbConn, err := postgres.Connect(&postgres.Config{
|
||||
|
@ -88,7 +88,7 @@ func main() {
|
|||
//usecases
|
||||
authUsecase, err := authusecase.New(&authusecase.Config{
|
||||
UserRepository: userRepository,
|
||||
TokenGenerator: jwt.NewTokenGenerator(os.Getenv("ACCESS_SECRET")),
|
||||
TokenGenerator: jwt.NewTokenGenerator(envutil.GetenvString("ACCESS_SECRET")),
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mode
|
||||
|
||||
import (
|
||||
"os"
|
||||
"github.com/zdam-egzamin-zawodowy/backend/pkg/util/envutil"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -14,7 +14,7 @@ const (
|
|||
var mode = DevelopmentMode
|
||||
|
||||
func init() {
|
||||
Set(os.Getenv(EnvKey))
|
||||
Set(envutil.GetenvString(EnvKey))
|
||||
}
|
||||
|
||||
func Set(value string) {
|
||||
|
|
Reference in New Issue