Static site hosting via tangled

Configurable port

Changed files
+5 -4
src
+5 -4
src/server.js
···
});
}
-
async start() {
-
this.app.listen(3000, () => {
-
console.log("Server is running on port 3000");
+
async start({ port }) {
+
this.app.listen(port, () => {
+
console.log(`Server is running on port ${port}`);
});
this.app.on("error", (error) => {
console.error("Server error:", error);
···
async function main() {
const args = yargs(process.argv.slice(2)).parse();
+
const port = args.port ?? args.p ?? 3000;
const configFilepath = args.config || "config.json";
const config = await Config.fromFile(configFilepath);
const handler = await Handler.fromConfig(config);
const server = new Server({
handler,
});
-
await server.start();
+
await server.start({ port });
}
main();