webserver-framework/index.ts

20 lines
820 B
TypeScript
Raw Normal View History

2023-07-15 19:24:01 +02:00
import { readFileSync } from 'node:fs';
import path from 'node:path';
import process from 'node:process';
2023-04-17 13:10:45 +02:00
const options = JSON.parse(readFileSync('./options.json', { encoding: 'utf-8' }));
2024-01-17 17:08:04 +01:00
const segments = path.resolve(process.argv[0]).split(path.sep);
2023-04-17 13:10:45 +02:00
process.env.JS_RUNTIME = segments[segments.length - 1].replace('.exe', '');
2024-01-17 17:08:04 +01:00
const fileSegments = path.resolve(process.argv[1]).split(path.sep);
const resolved = fileSegments.slice(0, fileSegments.length - 1).join(path.sep);
2023-04-17 13:10:45 +02:00
const srcDir = path.join(resolved, 'src');
const controllerDir = path.join(srcDir, 'controller');
options.srcDir = srcDir;
2023-07-15 19:24:01 +02:00
import { Controller } from './src/controller/index.js';
2023-04-17 13:10:45 +02:00
import dotenv from 'dotenv';
2024-01-17 17:08:04 +01:00
const env = dotenv.config().parsed ?? {};
2023-07-15 19:24:01 +02:00
const controller = new Controller(controllerDir, { ...options, env });
2023-04-17 13:10:45 +02:00
controller.init();