Add port flag

This commit is contained in:
sepia 2025-07-24 14:48:46 -05:00
parent 26e199375f
commit 0521400607
2 changed files with 16 additions and 4 deletions

BIN
server

Binary file not shown.

View File

@ -91,8 +91,20 @@ const app = new Elysia()
});
});
app.listen(3000, () => {
console.log(
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`,
);
const port = (() => {
let p = 3000;
for (let i = 0; i < Bun.argv.length; i++) {
if (Bun.argv[i] === '--port') {
const parsedPort = Number(Bun.argv[i + 1]);
if (!isNaN(parsedPort) && parsedPort > 0) {
p = parsedPort;
break;
}
}
}
return p;
})();
app.listen(port, () => {
console.log(`🦊 Elysia is running at ${app.server?.hostname}:${port}`);
});