-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.go
37 lines (33 loc) · 848 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package config
import (
"os"
)
const (
// AppName is the name of the app
appName = "go-api-boilerplate"
production = "production"
)
type Config struct {
Pepper string `env:"PEPPER"`
Env string `env:"ENV"`
FromEmail string `env:"EMAIL_FROM"`
Port int `env:"PORT"`
JWTSecret string `env:"JWT_SECRET"`
Mailgun MailgunConfig `json:"mailgun"`
Postgres PostgresConfig `json:"postgres"`
}
// Check if it is in production
func (c Config) isProduction() bool {
return c.Env == production
}
func GetConfig() Config {
return Config{
Pepper: os.Getenv("PEPPER"),
Env: os.Getenv("ENV"),
Mailgun: GetMailgunConfig(),
Postgres: GetPostgresConfig(),
FromEmail: os.Getenv("EMAIL_FROM"),
Port: getPort("PORT"),
JWTSecret: os.Getenv("JWT_SECRET"),
}
}