utils

package
v0.0.0-...-b1b50a1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package utils gathers various useful stuff

All listing or list-like information, usually cross-packages, are all gathered in this package in order to have a centralized location for information such as - Error codes list - Email account configuration and templates - Environment variables name

Index

Constants

View Source
const (

	// EmailTemplateUserRegistration when sending email for new user
	EmailTemplateUserRegistration = "user_registration"
	// EmailTemplateUserPwdReset when user is requesting a password reset
	EmailTemplateUserPwdReset = "user_pwd-reset"
)
View Source
const (
	// === Server
	EnvVarServerPort         = "ALUN_SERVER_MONOLITHIC_PORT"
	EnvVarServerIsMonolithic = "ALUN_SERVER_IS_MONOLITHIC"
	EnvVarMode               = "ALUN_MODE"
	// === Application: User
	EnvVarUserPort    = "ALUN_USER_PORT"
	EnvVarUserDbURL   = "ALUN_USER_DATABASE_URL"
	EnvVarUserSaltPwd = "ALUN_SECRET_PWD"
	EnvVarUserSaltJwt = "ALUN_SECRET_JWT"
	// === Application: Memo
	EnvVarMemoPort  = "ALUN_MEMO_PORT"
	EnvVarMemoDbURL = "ALUN_MEMO_DATABASE_URL"
	// === Email
	EnvVarEmailUsername = "ALUN_EMAIL_USERNAME"
	EnvVarEmailPassword = "ALUN_EMAIL_PASSWORD"
	EnvVarEmailHost     = "ALUN_EMAIL_HOST"
	EnvVarEmailPort     = "ALUN_EMAIL_PORT"
	EnvVarEmailSender   = "ALUN_EMAIL_SENDER"
)

List all environment variable names here to have a centralized list

View Source
const (
	AlunModeDev  = "Development"
	AlunModeTest = "Test"
	AlunModeProd = "Production"
)

List all running mode of the applications

Variables

This section is empty.

Functions

func IsDev

func IsDev() bool

IsDev returns true if the environment variables define a Development mode

func IsProd

func IsProd() bool

IsProd returns true if the environment variables define a production mode

func IsTest

func IsTest() bool

IsTest returns true if the environment variables define a test mode

Types

type AlunEmail

type AlunEmail struct {
	Account        communication.EmailConfiguration
	Sender         string
	TemplateFolder string
}

AlunEmail is the default production implementation of AlunEmailSender

func GetAlunEmail

func GetAlunEmail() *AlunEmail

GetAlunEmail loads the AlunEmail singleton

func (AlunEmail) SendNoReplyEmail

func (ae AlunEmail) SendNoReplyEmail(to []string, subject string, templateName string, emailData interface{}) error

SendNoReplyEmail sends an email from a no-reply account.

The returned error is only for telling the calling method that something went wrong. Parent method is not expected to tell the error content to the client and error handling must be done by checking the logs.

If templateName does not end up with `.html`, it is automatically appended

type AlunEmailSender

type AlunEmailSender interface {
	SendNoReplyEmail(to []string, subject string, templateName string, emailData interface{}) error
}

AlunEmailSender is a convenient interface to send an email from a specific no-reply Alun email

type DummyEmail

type DummyEmail struct {
}

DummyEmail prevents from sending real email and does nothing

func GetDummyEmail

func GetDummyEmail() *DummyEmail

GetDummyEmail generates a DummyEmail and keep the GetXXX singleton syntax to align with LoadAlunEmail

func (DummyEmail) SendNoReplyEmail

func (de DummyEmail) SendNoReplyEmail(to []string, subject string, templateName string, emailData interface{}) error

SendNoReplyEmail does nothing

Jump to

Keyboard shortcuts

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