feat: smtp config;
chore: added license comment blocks to the rest of backend and to sqlc schema & queries
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
type Config struct {
|
||||
Hostname string `mapstructure:"HOSTNAME"`
|
||||
Port string `mapstructure:"PORT"`
|
||||
Port uint16 `mapstructure:"PORT"`
|
||||
|
||||
DatabaseUrl string `mapstructure:"POSTGRES_URL"`
|
||||
RedisUrl string `mapstructure:"REDIS_URL"`
|
||||
@@ -39,6 +39,16 @@ type Config struct {
|
||||
JwtExpAccess int `mapstructure:"JWT_EXP_ACCESS"`
|
||||
JwtExpRefresh int `mapstructure:"JWT_EXP_REFRESH"`
|
||||
|
||||
SmtpEnabled bool `mapstructure:"SMTP_ENABLED"`
|
||||
SmtpServer string `mapstructure:"SMTP_SERVER"`
|
||||
SmtpPort uint16 `mapstructure:"SMTP_PORT"`
|
||||
SmtpUser string `mapstructure:"SMTP_USER"`
|
||||
SmtpPassword string `mapstructure:"SMTP_PASSWORD"`
|
||||
SmtpFrom string `mapstructure:"SMTP_FROM"`
|
||||
SmtpUseTLS bool `mapstructure:"SMTP_USE_TLS"`
|
||||
SmtpUseSSL bool `mapstructure:"SMTP_USE_SSL"`
|
||||
SmtpTimeout uint `mapstructure:"SMTP_TIMEOUT"`
|
||||
|
||||
PasswordMinLength int `mapstructure:"PASSWORD_MIN_LENGTH"`
|
||||
PasswordMaxLength int `mapstructure:"PASSWORD_MIN_LENGTH"`
|
||||
PasswordCheckNumbers bool `mapstructure:"PASSWORD_CHECK_NUMBERS"`
|
||||
@@ -47,7 +57,7 @@ type Config struct {
|
||||
PasswordCheckSymbols bool `mapstructure:"PASSWORD_CHECK_SYMBOLS"`
|
||||
PasswordCheckLeaked bool `mapstructure:"PASSWORD_CHECK_LEAKED"`
|
||||
|
||||
Environment string `mapstructure:"ENVIRONMENT"`
|
||||
Environment string `mapstructure:"ENVIRONMENT"`
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
@@ -62,6 +72,11 @@ func Load() (*Config, error) {
|
||||
viper.SetDefault("JWT_AUDIENCE", "easywish")
|
||||
viper.SetDefault("JWT_ISSUER", "easywish")
|
||||
|
||||
viper.SetDefault("SMTP_ENABLED", false)
|
||||
viper.SetDefault("SMTP_USE_TLS", false)
|
||||
viper.SetDefault("SMTP_USE_SSL", false)
|
||||
viper.SetDefault("SMTP_FROM", "An Easywish instance")
|
||||
|
||||
viper.SetDefault("PASSWORD_MIN_LENGTH", 6)
|
||||
viper.SetDefault("PASSWORD_MAX_LENGTH", 100)
|
||||
viper.SetDefault("PASSWORD_CHECK_NUMBERS", false)
|
||||
@@ -93,6 +108,16 @@ func Load() (*Config, error) {
|
||||
viper.BindEnv("JWT_EXP_ACCESS")
|
||||
viper.BindEnv("JWT_EXP_REFRESH")
|
||||
|
||||
viper.BindEnv("SMTP_ENABLED")
|
||||
viper.BindEnv("SMTP_SERVER")
|
||||
viper.BindEnv("SMTP_PORT")
|
||||
viper.BindEnv("SMTP_USER")
|
||||
viper.BindEnv("SMTP_PASSWORD")
|
||||
viper.BindEnv("SMTP_FROM")
|
||||
viper.BindEnv("SMTP_USE_TLS")
|
||||
viper.BindEnv("SMTP_USE_SSL")
|
||||
viper.BindEnv("SMTP_TIMEOUT")
|
||||
|
||||
viper.BindEnv("PASSWORD_MIN_LENGTH")
|
||||
viper.BindEnv("PASSWORD_MAX_LENGTH")
|
||||
viper.BindEnv("PASSWORD_CHECK_NUMBERS")
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of Easywish
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
// the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package errors
|
||||
|
||||
import (
|
||||
|
||||
18
backend/internal/services/smtp.go
Normal file
18
backend/internal/services/smtp.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of Easywish
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
// the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package services
|
||||
@@ -1,3 +1,20 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of Easywish
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
// the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package utils
|
||||
|
||||
func NewPointer[T any](d T) *T {
|
||||
|
||||
Reference in New Issue
Block a user