feat(auth): add database and auth token generation + storage
Some checks failed
build / Go-Build (push) Failing after 19s

This commit is contained in:
2026-01-17 21:40:17 +01:00
parent 093b67864c
commit 98a725caa4
9 changed files with 213 additions and 7 deletions

View File

@@ -0,0 +1,34 @@
package database
import (
"database/sql"
"log"
_ "github.com/glebarez/go-sqlite"
)
const FILENAME string = "storage.db"
var database *sql.DB
func OpenSQLite() error {
db, err := sql.Open("sqlite", FILENAME)
if err != nil {
return err
}
log.Println("Successfully connected to SQLite Database")
database = db
return nil
}
func InitDB() {
_, err := database.Exec(TOKENTABLECREATE)
if err != nil {
log.Fatal("Failed to init database:\n", err)
}
log.Println("Successfully initiated the Database!")
}
func Close() error {
return database.Close()
}