+5
-4
src/server.js
+5
-4
src/server.js
···
22
22
});
23
23
}
24
24
25
-
async start() {
26
-
this.app.listen(3000, () => {
27
-
console.log("Server is running on port 3000");
25
+
async start({ port }) {
26
+
this.app.listen(port, () => {
27
+
console.log(`Server is running on port ${port}`);
28
28
});
29
29
this.app.on("error", (error) => {
30
30
console.error("Server error:", error);
···
34
34
35
35
async function main() {
36
36
const args = yargs(process.argv.slice(2)).parse();
37
+
const port = args.port ?? args.p ?? 3000;
37
38
const configFilepath = args.config || "config.json";
38
39
const config = await Config.fromFile(configFilepath);
39
40
const handler = await Handler.fromConfig(config);
40
41
const server = new Server({
41
42
handler,
42
43
});
43
-
await server.start();
44
+
await server.start({ port });
44
45
}
45
46
46
47
main();