Add port flag
This commit is contained in:
parent
26e199375f
commit
0521400607
20
src/index.ts
20
src/index.ts
|
@ -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}`);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue