import { createServer } from 'node:http'
import { RequestHandler } from './RequestHandler';
import { Database } from './LocalDatabase';

export class Webserver {
    private port: number = 8080;
    private hostname: string = '0.0.0.0';
    private rh: RequestHandler;

    constructor(db: &Database) {
        this.rh = new RequestHandler(db);
    }

    start_server(): void {

        const server = createServer(this.rh.new_request);

        server.listen(this.port, this.hostname, () => {
            console.log('Server running at http://' + this.hostname  + ':' + this.port);
        });
    }
}