bot-framework/index.ts

33 lines
1023 B
TypeScript
Raw Permalink Normal View History

2024-03-31 12:46:28 +02:00
// require('dotenv').config({ override: true });
import { config } from 'dotenv';
config({ override: true });
if (!process.env.NODE_ENV)
process.env.NODE_ENV = 'development';
// eslint-disable-next-line no-console
console.log(`Starting in ${process.env.NODE_ENV} mode`);
import Controller from './src/middleware/Controller.js';
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { ControllerOptions } from './@types/Controller.js';
const optionsRaw = readFileSync('./options.jsonc', { encoding: 'utf-8' });
const lines = optionsRaw.split('\n');
const clean = [];
for (const line of lines)
{
if (line.startsWith('//'))
continue;
clean.push(line.replace(/\/\/.*/u, ''));
}
const options = JSON.parse(clean.join('\n')) as ControllerOptions;
const pkg = JSON.parse(readFileSync('./package.json', { encoding: 'utf-8' }));
const { version } = pkg;
const srcDir = path.join(process.cwd(), 'build', 'src');
options.rootDir = srcDir;
new Controller(options, version)
.build();