refactoring everything teehee (i'm so glad this isn't a team project)

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-08-01 01:39:18 +01:00
parent c684f0c7ae
commit 10f5f51e76
17 changed files with 970 additions and 547 deletions

24
db/db.go Normal file
View file

@ -0,0 +1,24 @@
package db
import (
"fmt"
"os"
"time"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
)
func InitDatabase() *sqlx.DB {
db, err := sqlx.Connect("postgres", "user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
if err != nil {
fmt.Fprintf(os.Stderr, "unable to create database connection pool: %v\n", err)
os.Exit(1)
}
db.SetConnMaxLifetime(time.Minute * 3)
db.SetMaxOpenConns(10)
db.SetMaxIdleConns(10)
return db
}