Skip to content

Commit

Permalink
--port param to node
Browse files Browse the repository at this point in the history
  • Loading branch information
WaviestBalloon committed May 2, 2023
1 parent 605d192 commit 0856efe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const nameList = readFileSync(join(__dirname, `../fillernames.txt`), "utf-8").split("\n");
const server = fastify({ logger: false });
let portNumber = 3000;
process.argv.forEach((val, index) => {
if (index < 2) return;
if (val === "--port") {
portNumber = parseInt(process.argv[index + 1]);
}
});

function toBinary(str: string) {
let result = "";
Expand Down Expand Up @@ -116,7 +123,7 @@ server.get("/", async (request: FastifyRequest, reply: FastifyReply) => {
}
});
});
server.listen({ port: 3000, host: "0.0.0.0" }, (err, address) => {
server.listen({ port: portNumber, host: "0.0.0.0" }, (err, address) => {
if (err) throw err;
console.log(`Server listening on ${address}`);
});
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rm -rf dist
npx tsc
node .
node . --port 3000

0 comments on commit 0856efe

Please sign in to comment.