Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/denoql/deps.ts>serve

DenoQL: GraphQL Scraper with Deno
Latest
function serve
import { serve } from "https://deno.land/x/denoql@v0.6.1/deps.ts";

Serves HTTP requests with the given handler.

You can specifies addr option, which is the address to listen on, in the form "host:port". The default is "0.0.0.0:8000".

The below example serves with the port 8000.

import { serve } from "https://deno.land/std@0.224.0/http/server.ts";
serve((_req) => new Response("Hello, world"));

You can change the listening address by addr option. The below example serves with the port 3000.

import { serve } from "https://deno.land/std@0.224.0/http/server.ts";
console.log("server is starting at localhost:3000");
serve((_req) => new Response("Hello, world"), { addr: ":3000" });

Parameters

handler: Handler

The handler for individual HTTP requests.

optional
options: ServeInit = [UNSUPPORTED]

The options. See ServeInit documentation for details.

Returns

Promise<void>