Documentation
¶
Index ¶
- func BuildAPIURL(subpaths ...string) string
- func CtxWithUserInfo(c *gin.Context, userinfo []byte)
- func GetLoggerFromCtx(ctx context.Context) *zap.SugaredLogger
- func GetUserFromCtx(ctx context.Context) *generated.User
- func GetUserInfoFromCtx(c *gin.Context) (*oidc.UserInfo, error)
- func NewAppConfig() error
- func NewErrorWithLocf(code ErrorCode, loc []string, format string, a ...any) error
- func NewErrorf(code ErrorCode, format string, a ...any) error
- func SetLoggerCtx(ctx context.Context, l *zap.SugaredLogger) context.Context
- func SetUserCtx(ctx context.Context, u *generated.User) context.Context
- func WrapErrorWithLocf(orig error, code ErrorCode, loc []string, format string, a ...interface{}) error
- func WrapErrorf(orig error, code ErrorCode, format string, a ...any) error
- type AppConfig
- type AppEnv
- type CtxGinKey
- type Decoder
- type DiscordConfig
- type Error
- type ErrorCode
- type KeyValueDbConfig
- type PostgresConfig
- type SuperAdminConfig
- type TwitchConfig
- type TwitchOidcConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAPIURL ¶
BuildAPIURL returns a fully-qualified URL with the given path elements accounting for reverse proxy configuration.
func CtxWithUserInfo ¶
func GetLoggerFromCtx ¶
func GetLoggerFromCtx(ctx context.Context) *zap.SugaredLogger
func NewAppConfig ¶
func NewAppConfig() error
NewAppConfig initializes app config from current environment variables. config can be replaced with subsequent calls.
func NewErrorWithLocf ¶
NewErrorWithLocf instantiates a new error with error location.
func SetLoggerCtx ¶
Types ¶
type AppConfig ¶
type AppConfig struct {
Postgres PostgresConfig
KV KeyValueDbConfig
TwitchOIDC TwitchOidcConfig
SuperAdmin SuperAdminConfig
Twitch TwitchConfig
Discord DiscordConfig
FrontendPort string `env:"FRONTEND_PORT"`
Domain string `env:"DOMAIN"`
APIPort string `env:"API_PORT"`
APIVersion string `env:"API_VERSION"`
ReverseProxyAPIPrefix *string `env:"REVERSE_PROXY_API_PREFIX"`
ProjectPrefix string `env:"PROJECT_PREFIX"`
AppEnv AppEnv `env:"APP_ENV"`
SigningKey string `env:"SIGNING_KEY"`
BuildVersion string `env:"BUILD_VERSION,-"`
CookieDomain string `env:"COOKIE_DOMAIN"`
LoginCookieKey string `env:"LOGIN_COOKIE_KEY"`
}
AppConfig contains app settings.
var ( // Config returns the app global config initialized from environment variables. // [Read] locks not needed if there are no writes involved. Config is only populated at startup so there won't be any more writes. Config *AppConfig )
type DiscordConfig ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error that could be wrapping another error, It includes a code for determining what triggered the error.
type ErrorCode ¶
type ErrorCode string
const ( ErrorCodeAlreadyExists ErrorCode = "AlreadyExists" ErrorCodeInvalidArgument ErrorCode = "InvalidArgument" ErrorCodeSignedOut ErrorCode = "SignedOut" ErrorCodeInvalidRole ErrorCode = "InvalidRole" ErrorCodeInvalidScope ErrorCode = "InvalidScope" ErrorCodeInvalidUUID ErrorCode = "InvalidUUID" ErrorCodeNotFound ErrorCode = "NotFound" ErrorCodeOIDC ErrorCode = "OIDC" ErrorCodePrivate ErrorCode = "Private" ErrorCodeRequestValidation ErrorCode = "RequestValidation" ErrorCodeResponseValidation ErrorCode = "ResponseValidation" ErrorCodeUnauthenticated ErrorCode = "Unauthenticated" ErrorCodeUnknown ErrorCode = "Unknown" )
Notes: - 'Private' marks an error to be hidden in response.
type KeyValueDbConfig ¶
KeyValueDbConfig contains key-value db settings.
type PostgresConfig ¶
type PostgresConfig struct {
// Port represents the db port to use in the application, depending on setup (dockerized or not).
Port string `env:"DB_PORT"`
User string `env:"POSTGRES_USER"`
Password string `env:"POSTGRES_PASSWORD"`
Server string `env:"POSTGRES_SERVER"`
DB string `env:"POSTGRES_DB"`
// Ent with pgx v5 will allow to trace queries.
TraceEnabled bool `env:"POSTGRES_TRACE,false"`
}
type SuperAdminConfig ¶
type SuperAdminConfig struct {
// manually set a user to be superadmin.
// Alternatively we could have a special admin dashboard but we can stick to twitch login for now.
Email string `env:"SUPERADMIN_EMAIL"`
}
type TwitchConfig ¶
type TwitchOidcConfig ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
ent
|
|
|
privacy/token
Package token provides policy wrappers / getters for queries and mutations during password reset, sign-up
|
Package token provides policy wrappers / getters for queries and mutations during password reset, sign-up |
|
privacy/utils
Package utils is a helper for working with ent policies
|
Package utils is a helper for working with ent policies |
|
schema
file: internal/ent/schema/refreshtoken.go
|
file: internal/ent/schema/refreshtoken.go |
| * | |
|
nolint: tagliatelle
|
nolint: tagliatelle |
|
utils
|
|
Click to show internal directories.
Click to hide internal directories.