continued

implemented HTMX
implemented ORM (sequelize)
This commit is contained in:
Kai Waggeling 2025-11-29 21:56:21 +01:00
parent 2a9bd4e81b
commit d756a192e4
71 changed files with 3822 additions and 694 deletions

View file

@ -2,17 +2,41 @@
import mysql from "mysql2/promise";
import {
generateOTPSecret
} from "./otp.mjs";
getConfig
} from "./config.mjs";
// Create the connection to database
const connection = await mysql.createConnection({
host: '10.0.0.31',
port: 33063,
database: 'glauth',
user: 'glauth',
password: 'b848dc7aa44b66bbcc1e5991a6ae45ce'
});
const configData = await getConfig();
var connection = null;
await connect();
export async function connect(params) {
if (connection != null) {
connection.destroy();
}
// Create the connection to database
connection = await mysql.createConnection({
host: configData.database.host,
port: configData.database.port,
database: configData.database.database,
user: configData.database.username,
password: configData.database.password
});
await connection.connect();
connection.on('connection', async () => {
console.log("database connection successful!");
});
connection.on('error', async (mysqlError) => {
if (mysqlError.code == "PROTOCOL_CONNECTION_LOST") {
console.log("database connection lost. reconnecting...");
await connect();
}
});
}
export async function login(username, password) {
try {