webserver-framework/index.ts
2024-01-17 20:55:55 +02:00

18 lines
686 B
TypeScript

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(path.sep);
process.env.JS_RUNTIME = segments[segments.length - 1].replace('.exe', '');
const srcDir = path.join(process.cwd(), 'build', 'src');
const controllerDir = path.join(srcDir, 'controller');
options.srcDir = srcDir;
import { Controller } from './src/controller/index.js';
import dotenv from 'dotenv';
const env = dotenv.config().parsed ?? {};
const controller = new Controller(controllerDir, { ...options, env });
controller.init();