From 74551991772d40be65ab740719c4f9f640bb02a7 Mon Sep 17 00:00:00 2001 From: Adrian Victor Date: Sat, 16 Nov 2024 15:32:56 -0300 Subject: [PATCH] Added port option in config.json --- .gitignore | 5 ++++- package.json | 2 +- zephyrus.ts | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 91eeade..8a58cfa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ package-lock.json certificate.crt private.key main.js -dist \ No newline at end of file +dist +config.json +www +custom.css \ No newline at end of file diff --git a/package.json b/package.json index efee649..c585d6f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "version": "1.0.0", "private": false, "scripts": { - "start": "ts-node main.ts", + "start": "ts-node zephyrus.ts", "build" : "npx tsc" }, "devDependencies": { diff --git a/zephyrus.ts b/zephyrus.ts index 0553555..dade837 100644 --- a/zephyrus.ts +++ b/zephyrus.ts @@ -24,7 +24,8 @@ function requestHandler(request: IncomingMessage, response: ServerResponse) { const path_ = decodeURI(parsed.pathname || '/'); const serversidePath = path.join(config.serverRoot + path_); const defaultPagePath = path.join(config.serverRoot + config.defaultPage); - const finalPath = config.useDefaultPage && request.url == '/' ? path.normalize(defaultPagePath) : serversidePath; + const finalPath = (config.useDefaultPage && request.url == '/') ? path.normalize(defaultPagePath) : serversidePath; + // console.log(finalPath) function showError(code: number, log: boolean = config.logErrors, info: string = 'no more information about the error was provided.') { if (log) { @@ -125,6 +126,6 @@ function requestHandler(request: IncomingMessage, response: ServerResponse) { }) } -server.listen(3000, () => { - console.log("Started at https://localhost:3000") +server.listen(config.port, () => { + console.log(`Started at http${config.useHTTPS ? 's' : ''}://localhost:${config.port}`) }) \ No newline at end of file