Added port option in config.json
This commit is contained in:
parent
e9c247baea
commit
7455199177
3 changed files with 9 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -4,3 +4,6 @@ certificate.crt
|
||||||
private.key
|
private.key
|
||||||
main.js
|
main.js
|
||||||
dist
|
dist
|
||||||
|
config.json
|
||||||
|
www
|
||||||
|
custom.css
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "ts-node main.ts",
|
"start": "ts-node zephyrus.ts",
|
||||||
"build" : "npx tsc"
|
"build" : "npx tsc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ function requestHandler(request: IncomingMessage, response: ServerResponse) {
|
||||||
const path_ = decodeURI(parsed.pathname || '/');
|
const path_ = decodeURI(parsed.pathname || '/');
|
||||||
const serversidePath = path.join(config.serverRoot + path_);
|
const serversidePath = path.join(config.serverRoot + path_);
|
||||||
const defaultPagePath = path.join(config.serverRoot + config.defaultPage);
|
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.') {
|
function showError(code: number, log: boolean = config.logErrors, info: string = 'no more information about the error was provided.') {
|
||||||
if (log) {
|
if (log) {
|
||||||
|
|
@ -125,6 +126,6 @@ function requestHandler(request: IncomingMessage, response: ServerResponse) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
server.listen(3000, () => {
|
server.listen(config.port, () => {
|
||||||
console.log("Started at https://localhost:3000")
|
console.log(`Started at http${config.useHTTPS ? 's' : ''}://localhost:${config.port}`)
|
||||||
})
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue