feat: use PORT environment variable to change port (#468)
This can be useful when deploying to other providers. Also more convenient for projects with multiple developers with port preferences --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
co-authored by
Asher Gomez
parent
65e6385bc4
commit
6e1874ccca
+2
-1
@@ -67,9 +67,10 @@ export async function createHandler(
|
||||
const ctx = await ServerContext.fromManifest(routes, opts);
|
||||
return ctx.handler();
|
||||
}
|
||||
|
||||
export async function start(routes: Manifest, opts: StartOptions = {}) {
|
||||
const ctx = await ServerContext.fromManifest(routes, opts);
|
||||
opts.port ??= 8000;
|
||||
opts.port ??= parseInt(Deno.env.get("PORT") || "8000");
|
||||
if (opts.experimentalDenoServe === true) {
|
||||
// @ts-ignore as `Deno.serve` is still unstable.
|
||||
await Deno.serve(ctx.handler() as Deno.ServeHandler, opts);
|
||||
|
||||
Reference in New Issue
Block a user