actions-test/src/main.ts

56 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-02-28 14:44:10 +01:00
declare global {
var debug: boolean;
}
import express from "express";
import https from "https";
import http from "http";
import { Command } from "commander";
import { oConf } from "./sys/config.js"
import { log } from "./sys/log.js"
import { connectToDB } from "./sys/db.js"
import bruteforce from "./sys/bruteforce.js"
import { getSettings, setSettings } from "./sys/settings.js"
import { fullSetup, partiellSetup } from "./setup/config.js"
const config = {
version: "0.0.1"
};
const program = new Command();
program
.name("Outbag Server")
.description("The default way to host your own Outbag server.")
.version(config.version);
program
.option("-c, --config <path>", "Start the Outbag server with a config file.")
.option("-d, --debug", "Start the Outbag server with more log output.")
.option("-s, --setup", "Start the Server Setup Tool")
.action(({ config, debug, setup }) => {
let dofullSetup = false;
global.debug = debug != null;
if (config) {
log("System", "Starting with config:", config);
if(!oConf.connect(config)) dofullSetup = true;
}
if(setup || dofullSetup){
if(dofullSetup) fullSetup();
else partiellSetup();
}else{
startServer();
}
});
program.parse();
async function startServer() {
await connectToDB();
const server = express();
server.use(bruteforce);
}