repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

pico / pgs
Eric Bower · 20 Sep 24

config.go

 1package pgs
 2
 3import (
 4	"github.com/picosh/pico/shared"
 5)
 6
 7var maxSize = uint64(25 * shared.MB)
 8var maxAssetSize = int64(10 * shared.MB)
 9
10func NewConfigSite() *shared.ConfigSite {
11	domain := shared.GetEnv("PGS_DOMAIN", "pgs.sh")
12	port := shared.GetEnv("PGS_WEB_PORT", "3000")
13	protocol := shared.GetEnv("PGS_PROTOCOL", "https")
14	storageDir := shared.GetEnv("PGS_STORAGE_DIR", ".storage")
15	minioURL := shared.GetEnv("MINIO_URL", "")
16	minioUser := shared.GetEnv("MINIO_ROOT_USER", "")
17	minioPass := shared.GetEnv("MINIO_ROOT_PASSWORD", "")
18	dbURL := shared.GetEnv("DATABASE_URL", "")
19	secret := shared.GetEnv("PICO_SECRET", "")
20	if secret == "" {
21		panic("must provide PICO_SECRET environment variable")
22	}
23
24	cfg := shared.ConfigSite{
25		Secret:       secret,
26		Domain:       domain,
27		Port:         port,
28		Protocol:     protocol,
29		DbURL:        dbURL,
30		StorageDir:   storageDir,
31		MinioURL:     minioURL,
32		MinioUser:    minioUser,
33		MinioPass:    minioPass,
34		Space:        "pgs",
35		MaxSize:      maxSize,
36		MaxAssetSize: maxAssetSize,
37		Logger:       shared.CreateLogger("pgs"),
38	}
39
40	return &cfg
41}