/*
 * Baxxon
 * Copyright(c) 2000-2026 Lorne Taylor
 */

// listens for http connections 
// passes request and response to application module

import http from "node:http";
import https from "node:https";
import fs from "node:fs";
import path from "node:path";
import app, { Bx } from "./app.js";
import log from "./logger.js";

// HTTP server ::::::::::::::::::::::::::::::

const bx = new Bx(); // Use Bx to get default options
const host = bx.op.server.host || "0.0.0.0";
const portHttp = bx.op.server.portHttp || 3000;
const portHttps = bx.op.server.portHttps || 3001;

http.createServer(app)
	.on('error', (err)=>{
		console.log("[node] HTTP server failed");
	})
	.listen(portHttp, host, ()=>{ 
		console.log(`[node] Server started ${host}:${portHttp}`);
		console.log('[node] type CTRL-C to exit');
		log.banner();
	})

