hmn/src/config/types.go

138 lines
2.8 KiB
Go
Raw Normal View History

2021-03-09 08:05:07 +00:00
package config
import (
"fmt"
2023-01-02 21:52:41 +00:00
"github.com/jackc/pgx/v5/tracelog"
2021-05-06 09:12:18 +00:00
"github.com/rs/zerolog"
)
2021-03-09 08:05:07 +00:00
type Environment string
const (
Live Environment = "live"
Beta = "beta"
Dev = "dev"
)
type HMNConfig struct {
2023-05-17 19:33:27 +00:00
Env Environment
Addr string
PrivateAddr string
BaseUrl string
LogLevel zerolog.Level
Postgres PostgresConfig
Auth AuthConfig
Admin AdminConfig
Email EmailConfig
DigitalOcean DigitalOceanConfig
Discord DiscordConfig
Twitch TwitchConfig
Matrix MatrixConfig
2023-05-17 19:33:27 +00:00
EpisodeGuide EpisodeGuide
DevConfig DevConfig
PreviewGeneration PreviewGenerationConfig
2024-01-28 17:12:59 +00:00
Calendars []CalendarSource
2021-03-09 08:05:07 +00:00
}
type PostgresConfig struct {
User string
Password string
Hostname string
Port int
DbName string
2023-01-02 21:52:41 +00:00
LogLevel tracelog.LogLevel
MinConn int32
MaxConn int32
2021-03-09 08:05:07 +00:00
}
2021-03-27 21:10:11 +00:00
type AuthConfig struct {
CookieDomain string
CookieSecure bool
}
2021-06-22 09:50:40 +00:00
type DigitalOceanConfig struct {
AssetsSpacesKey string
AssetsSpacesSecret string
AssetsSpacesRegion string
AssetsSpacesEndpoint string
AssetsSpacesBucket string
AssetsPublicUrlRoot string
RunFakeServer bool
FakeAddr string
2021-06-22 09:50:40 +00:00
}
2021-08-08 20:05:52 +00:00
type EmailConfig struct {
ServerAddress string
ServerPort int
FromAddress string
MailerUsername string
MailerPassword string
FromName string
ForceToAddress string
2021-08-08 20:05:52 +00:00
}
type DiscordConfig struct {
BotToken string
BotUserID string
2021-08-16 04:40:56 +00:00
OAuthClientID string
OAuthClientSecret string
2022-08-05 02:00:15 +00:00
GuildID string
MemberRoleID string
ShowcaseChannelID string
LibraryChannelID string
StreamsChannelID string
}
2022-03-22 18:07:43 +00:00
type TwitchConfig struct {
ClientID string
ClientSecret string
EventSubSecret string // NOTE(asaf): Between 10-100 chars long. Anything will do.
BaseUrl string
BaseIDUrl string
}
type MatrixConfig struct {
Username string
Password string
BaseUrl string
AnnouncementsRoomID string
}
2024-01-28 17:12:59 +00:00
type CalendarSource struct {
Name string
Url string
}
type EpisodeGuide struct {
CineraOutputPath string
Projects map[string]string // NOTE(asaf): Maps from slugs to default episode guide topic
}
2021-09-24 00:12:46 +00:00
type AdminConfig struct {
AtomUsername string
AtomPassword string
}
type DevConfig struct {
LiveTemplates bool // load templates live from the filesystem instead of embedding them
}
2023-05-17 19:33:27 +00:00
type PreviewGenerationConfig struct {
FFMpegPath string
CPULimitPath string
}
func init() {
if Config.EpisodeGuide.Projects == nil {
Config.EpisodeGuide.Projects = make(map[string]string)
}
}
2021-03-09 08:05:07 +00:00
func (info PostgresConfig) DSN() string {
return fmt.Sprintf("user=%s password=%s host=%s port=%d dbname=%s", info.User, info.Password, info.Hostname, info.Port, info.DbName)
}