webserver-framework/index.ts

18 lines
789 B
TypeScript
Raw Normal View History

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