Added port option in config.json
This commit is contained in:
parent
e9c247baea
commit
7455199177
3 changed files with 9 additions and 5 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -3,4 +3,7 @@ package-lock.json
|
|||
certificate.crt
|
||||
private.key
|
||||
main.js
|
||||
dist
|
||||
dist
|
||||
config.json
|
||||
www
|
||||
custom.css
|
||||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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}`)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue