config

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2023 License: AGPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Sender = `no-reply@uspy.me`
	Name   = `USPY`
)

Email defaults

View Source
const (
	VerificationSubject     = `Verifique sua conta para usar o USPY =)`
	PasswordRecoverySubject = `Aqui está seu link de recuperação de senha do USPY =)`

	VerificationContent = `` /* 185-byte string literal not displayed */

	PasswordRecoveryContent = `` /* 192-byte string literal not displayed */

)

Verification

Variables

This section is empty.

Functions

func Setup

func Setup()

Setup parses the .env file (or uses defaults) to determine environment constants and variables

func TestSetup

func TestSetup()

TestSetup is used by the emulator, it will only load required defaults, no project-related identifiers

Types

type Config

type Config struct {
	Domain          string `envconfig:"USPY_DOMAIN" required:"true" default:"127.0.0.1"`
	Port            string `envconfig:"USPY_PORT" required:"true" default:"8080"` // careful with this because cloud run must run on port 8080
	JWTSecret       string `envconfig:"USPY_JWT_SECRET" required:"true" default:"my_secret"`
	Mode            string `envconfig:"USPY_MODE" required:"true" default:"local"`
	AESKey          string `envconfig:"USPY_AES_KEY" required:"true" default:"71deb5a48500599862d9e2170a60f90194a49fa81c24eacfe9da15cb76ba8b11"` // only used in dev
	RateLimit       string `envconfig:"USPY_RATE_LIMIT"`                                                                                         // see github.com/ulule/limiter for more info
	AuthEndpoint    string `envconfig:"USPY_AUTH_ENDPOINT" required:"true" default:"127.0.0.1:8081"`
	FrontOriginHost string `envconfig:"USPY_FRONT_ORIGIN_HOST" default:"http://127.0.0.1:3000"`

	FirestoreKeyPath  string `envconfig:"USPY_FIRESTORE_KEY"`
	MockFirestoreData bool   `envconfig:"USPY_MOCK_FIRESTORE_DATA" default:"false"`

	ProjectID string `envconfig:"USPY_PROJECT_ID"`

	Mailjet // email verification is needed in production
}

Config is the default configuration object, for more info see README.md

var Env Config

Env is the default variable for the environment to be loaded

func (Config) Identify

func (c Config) Identify() string

Identify returns the type of the authentication being used by the configuration object

func (Config) IsDev

func (c Config) IsDev() bool

IsDev returns whether the configuration environment is in development mode

func (Config) IsLocal

func (c Config) IsLocal() bool

IsLocal returns whether the configuration environment is in local mode

func (Config) IsProd

func (c Config) IsProd() bool

IsProd returns whether the configuration environment is in production mode

func (Config) IsUsingKey

func (c Config) IsUsingKey() bool

IsUsingKey returns whether a firestore key is being used to authenticate with Firestore

func (Config) IsUsingProjectID

func (c Config) IsUsingProjectID() bool

IsUsingProjectID returns whether the GCP Project ID is being used to authenticate with Firestore

func (Config) Redact

func (c Config) Redact() Config

Redact can be used to print the environment config without exposing secret

type GeneralConfig

type GeneralConfig interface {
	Identify() string
}

GeneralConfig is the interface for an environment configuration. It has only one method that must identify the type of authentication used

type Mailjet

type Mailjet struct {
	APIKey string `envconfig:"USPY_MAILJET_KEY"`
	Secret string `envconfig:"USPY_MAILJET_SECRET"`
	// contains filtered or unexported fields
}

Mailjet is the email client object

func (*Mailjet) Send

func (m *Mailjet) Send(target, subject, content string) error

Send sends an email.

It takes a target email recipient, subject and HTML content.

func (*Mailjet) Setup

func (m *Mailjet) Setup()

Setup initializes the mailjet client using its API Key and Secret

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL