From 71e09a86f6d5058b940aa706733042bf6d8bf1bc Mon Sep 17 00:00:00 2001 From: Eden Kirin Date: Mon, 23 Oct 2023 23:41:46 +0200 Subject: [PATCH] Add secret key --- app/cfg/cfg.go | 2 ++ app/main.go | 9 ++++++++- config.template.yaml | 24 ++++++++++++++++++++++++ migrations/V0000__initial.sql | 0 migrations/V0001__create_users.sql | 16 ++++++++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 config.template.yaml create mode 100644 migrations/V0000__initial.sql create mode 100644 migrations/V0001__create_users.sql diff --git a/app/cfg/cfg.go b/app/cfg/cfg.go index bf93fb4..3ed641a 100644 --- a/app/cfg/cfg.go +++ b/app/cfg/cfg.go @@ -18,6 +18,7 @@ type configStruct struct { Password string `yaml:"password" json:"-"` } `yaml:"database"` Application struct { + SecretKey string `yaml:"secretKey" json:"-"` LogLevel string `yaml:"logLevel"` LogFile string `yaml:"logFile"` Debug bool `yaml:"debug"` @@ -81,6 +82,7 @@ func Init() { maskedCfg := Config maskedCfg.Database.Password = "**password hidden**" maskedCfg.SMTP.Password = "**password hidden**" + maskedCfg.Application.SecretKey = "**secret key hidden**" fmt.Println("--- CONFIG -------------------------------") fmt.Println(maskedCfg) diff --git a/app/main.go b/app/main.go index 00bfde9..ec787c7 100644 --- a/app/main.go +++ b/app/main.go @@ -1,7 +1,10 @@ -// Package main an example on how to naming your routes & use the custom 'url path' Jet Template Engine. package main import ( + "iris-test/app/cfg" + "iris-test/app/db" + "iris-test/app/logging" + "github.com/kataras/iris/v12" ) @@ -35,6 +38,10 @@ var users = []User{ } func main() { + cfg.Init() + logging.Init() + db.InitDB() + app := iris.New() app.RegisterView(iris.Jet("./app/templates", ".jet").Reload(true)) diff --git a/config.template.yaml b/config.template.yaml new file mode 100644 index 0000000..497b25d --- /dev/null +++ b/config.template.yaml @@ -0,0 +1,24 @@ +# Database credentials +database: + host: "localhost" + port: 5432 + name: "iristest" + username: "iristest" + password: "iristest" + +application: + secretKey: "secret-key" + logLevel: info + logFile: "/var/log/test/iristest.log" # null to disable logging to file + debugSQL: true + isProduction: false + loopDelay: 3000 + +smtp: + host: "smtp-host" + port: 587 + username: "smtp-username" + password: "smtp-password" + startTLS: true + useTLS: false + fromEmail: "vitalwatchdog " diff --git a/migrations/V0000__initial.sql b/migrations/V0000__initial.sql new file mode 100644 index 0000000..e69de29 diff --git a/migrations/V0001__create_users.sql b/migrations/V0001__create_users.sql new file mode 100644 index 0000000..a4243aa --- /dev/null +++ b/migrations/V0001__create_users.sql @@ -0,0 +1,16 @@ +CREATE TABLE IF NOT EXISTS users +( + id uuid DEFAULT gen_random_uuid() PRIMARY KEY NOT NULL, + email varchar(100) NOT NULL, + first_name varchar(50), + last_name varchar(50), + password varchar(100) NOT NULL, + is_active boolean default TRUE, + created_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL, + updated_at timestamp WITH TIME ZONE DEFAULT NOW() NOT NULL +); + +CREATE UNIQUE INDEX IF NOT EXISTS users_id_uindex + ON users (id); +CREATE UNIQUE INDEX IF NOT EXISTS email_uindex + ON users (email);