From 7f06d7c29d0a288f90d465b54316f65fed3ea6e6 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 17 Jan 2022 08:21:43 +0100 Subject: [PATCH] Setting a custom port is now possible --- index.js | 5 ++++- posts.json | 16 +--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 06e8033..c593cf3 100644 --- a/index.js +++ b/index.js @@ -85,4 +85,7 @@ server.get('/comment', function get(req, res) { res.send("err1") }) -server.listen(process.argv[1] | process.env.PORT | 8080) +let PORT = process.argv[2] +if(!PORT) PORT = process.env.PORT +if(!PORT) PORT = 8080 +server.listen(Number(PORT), () => console.log(PORT)) diff --git a/posts.json b/posts.json index 7f51d7a..b79e34a 100644 --- a/posts.json +++ b/posts.json @@ -1,15 +1 @@ -[ - { - "title": "Default post", - "content": "This is the first post, it was here since the beginning.\n(Remove the space after the '[' and before the ']')\n [ * [* text *] * ] [ ** [** text **] ** ] [ *** [*** text ***] *** ] [ _ [_ text _] _ ] [ *_ [*_ text _*] _* ] [ **_ [**_ text _**] _** ] [ ***_ [***_ text _***] _*** [ **_ [**_ text _**] _** ] [ ***_ [***_ text _***] _*** ] [ \" [\" text \"] \" ]", - "author": "root", - "comments": [ - { - "title": "The first comment", - "content": "This is the first comment, it was here since the beginning.", - "author": "Anonymous", - "comments": [] - } - ] - } -] +[{"title":"Default post","content":"This is the first post, it was here since the beginning.\n(Remove the space after the '[' and before the ']')\n [ * [* text *] * ] [ ** [** text **] ** ] [ *** [*** text ***] *** ] [ _ [_ text _] _ ] [ *_ [*_ text _*] _* ] [ **_ [**_ text _**] _** ] [ ***_ [***_ text _***] _*** [ **_ [**_ text _**] _** ] [ ***_ [***_ text _***] _*** ] [ \" [\" text \"] \" ]","author":"root","comments":[{"title":"The first comment","content":"This is the first comment, it was here since the beginning.","author":"Anonymous","comments":[]}]}] \ No newline at end of file