Skip to main content


Super-agent driven library for testing Deno HTTP servers.
method Server.prototype.listenAndServeTls
import { Server } from "";

Create a listener on the server, accept incoming connections, upgrade them to TLS, and handle requests on these connections with the given handler.

If the server was constructed without a specified port, 443 is used.

If the server was constructed with the hostname omitted from the options, the non-routable meta-address is used.

Throws a server closed error if the server has been closed.

import { Server } from "";

const port = 4505;
const handler = (request: Request) => {
  const body = `Your user-agent is:\n\n${request.headers.get(
  ) ?? "Unknown"}`;

  return new Response(body, { status: 200 });

const server = new Server({ port, handler });

const certFile = "/path/to/certFile.crt";
const keyFile = "/path/to/keyFile.key";

console.log("server listening on https://localhost:4505");

await server.listenAndServeTls(certFile, keyFile);


certFile: string

The path to the file containing the TLS certificate.

keyFile: string

The path to the file containing the TLS private key.