refactor(esm): migrate server and tests from CommonJS to ESM

Convert all server/, test, and setup files from require()/module.exports
to import/export syntax. Activate ESM globally via "type": "module" in
package.json and load dotenv via --import dotenv/config in npm scripts.
This commit is contained in:
Ulas
2026-04-03 23:11:20 +02:00
parent 2f6127911e
commit b139eea623
24 changed files with 113 additions and 154 deletions
+4 -11
View File
@@ -5,14 +5,10 @@
* Abhängigkeiten: server/db.js, bcrypt, dotenv
*/
'use strict';
require('dotenv').config();
const readline = require('node:readline');
const bcrypt = require('bcrypt');
const db = require('./server/db');
const os = require('node:os');
import readline from 'node:readline';
import bcrypt from 'bcrypt';
import * as db from './server/db.js';
import os from 'node:os';
function getLocalIP() {
const interfaces = os.networkInterfaces();
@@ -67,9 +63,6 @@ function promptPassword(question) {
async function main() {
console.log('\n=== Oikos Setup ===\n');
// Datenbank initialisieren
db.init();
// Prüfen ob bereits Admin vorhanden
const existingAdmin = db.get()
.prepare("SELECT id FROM users WHERE role = 'admin' LIMIT 1")