feat: experimental support for Deno.serve (#681)
The experimental support can be enabled through the `experimentalDenoServe` option for `start()`. Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
co-authored by
Luca Casonato
parent
b7f0d5c860
commit
ba7c78bcc2
+8
-5
@@ -60,10 +60,13 @@ export interface DenoConfig {
|
||||
|
||||
export { ServerContext };
|
||||
|
||||
export async function start(
|
||||
routes: Manifest,
|
||||
opts: StartOptions = {},
|
||||
) {
|
||||
export async function start(routes: Manifest, opts: StartOptions = {}) {
|
||||
const ctx = await ServerContext.fromManifest(routes, opts);
|
||||
await serve(ctx.handler(), opts);
|
||||
opts.port ??= 8000;
|
||||
if (opts.experimentalDenoServe === true) {
|
||||
// @ts-ignore as `Deno.serve` is still unstable.
|
||||
await Deno.serve(ctx.handler() as Deno.ServeHandler, opts);
|
||||
} else {
|
||||
await serve(ctx.handler(), opts);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user