Initial commit: IT Nexus Web-App

This commit is contained in:
2026-06-01 20:49:07 +02:00
commit 8023765e6c
387 changed files with 106900 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
const Database = require('better-sqlite3');
const path = require('path');
require('dotenv').config();
const DB_PATH = process.env.DATABASE_PATH || './database.sqlite';
let db = null;
function getDatabase() {
if (!db) {
try {
db = new Database(DB_PATH);
// Enable foreign keys
db.pragma('foreign_keys = ON');
// Performance optimizations
db.pragma('journal_mode = WAL');
db.pragma('synchronous = NORMAL');
console.log('📦 Database connected successfully');
} catch (error) {
console.error('❌ Database connection failed:', error.message);
throw error;
}
}
return db;
}
function closeDatabase() {
if (db) {
db.close();
db = null;
console.log('📦 Database connection closed');
}
}
module.exports = {
getDatabase,
closeDatabase
};

14
backend/src/config/jwt.js Normal file
View File

@@ -0,0 +1,14 @@
require('dotenv').config();
const JWT_CONFIG = {
secret: process.env.JWT_SECRET || 'default-secret-change-in-production',
expiresIn: process.env.JWT_EXPIRATION || '8h',
algorithm: 'HS256'
};
// Validate that JWT_SECRET is set
if (!process.env.JWT_SECRET) {
console.warn('⚠️ WARNING: JWT_SECRET not set in .env file. Using default secret (INSECURE!)');
}
module.exports = JWT_CONFIG;