Use env var PORT instead of --port flag

This commit is contained in:
sepia 2025-07-24 15:18:19 -05:00
parent 419904fb3c
commit 6bea470c38
2 changed files with 2 additions and 16 deletions

View File

@ -3,7 +3,5 @@ repos:
hooks: hooks:
- id: just-format - id: just-format
name: just format name: just format
entry: just format
language: system language: system
types: [file] entry: bash -c "just format"
files: "\\.(ts|tsx|js|jsx|json|css|scss|html|md)$"

View File

@ -91,19 +91,7 @@ const app = new Elysia()
}); });
}); });
const port = (() => { const port = Number(process.env.PORT || 3000);
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, () => { app.listen(port, () => {
console.log(`🦊 Elysia is running at ${app.server?.hostname}:${port}`); console.log(`🦊 Elysia is running at ${app.server?.hostname}:${port}`);