feat: implement basic file watcher and session updater

This commit is contained in:
Haileyesus
2026-03-25 10:46:08 +03:00
parent f187e22976
commit 3e268e201a
18 changed files with 1448 additions and 377 deletions

View File

@@ -1,6 +1,37 @@
import express from 'express';
import http from 'http';
import { userDb } from "@/shared/database/repositories/users.js";
import { initializeDatabase } from '@/shared/database/init-db.js';
import { initializeWatcher } from '@/modules/watcher/file-watcher.js';
console.log("----------------Hello there, Refactored Runner!-------------------");
console.log("User db initialized");
console.log("First user:", userDb.getFirstUser());
const app = express();
const server = http.createServer(app);
const serverPortEnv = process.env.SERVER_PORT;
const SERVER_PORT = serverPortEnv ? Number.parseInt(serverPortEnv) : 3001;
if (Number.isNaN(SERVER_PORT)) {
throw new Error(`Invalid SERVER_PORT value: ${serverPortEnv}`);
}
const HOST = process.env.HOST || '0.0.0.0';
async function main() {
try {
await initializeDatabase();
server.listen(SERVER_PORT, HOST, async () => {
console.log(`Server is running on http://${HOST}:${SERVER_PORT}`);
await initializeWatcher();
});
} catch (error) {
console.error("Failed to initialize database:", error);
process.exit(1);
}
}
await main();