Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/http/server.js>Server

A JavaScript extension package for building strong and modern applications.
Latest
class Server
import { Server } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/http/server.js";

A unified HTTP server interface.

Constructors

new
Server(impl, options)

Properties

readonly
hostname

The hostname of which the server is listening on, only available after the server is ready and the server type is classic.

readonly
port

The port of which the server is listening on, only available after the server is ready and the server type is classic.

readonly
ready

A promise that resolves when the server is ready to accept connections.

Methods

close(force?)

Closes the server and stops it from accepting new connections. By default, this function will wait until all active connections to close before shutting down the server. However, we can force the server to close all active connections and shutdown immediately by setting the force parameter to true.

NOTE: In Node.js, the force parameter is only available for HTTP servers, it has no effect on HTTP2 servers.

ref()

Opposite of unref(), calling ref() on a previously unrefed server will not let the program exit if it's the only server left (the default behavior). If the server is refed calling ref() again will have no effect.

Calling unref() on a server will allow the program to exit if this is the only active server in the event system. If the server is already unrefed callingunref() again will have no effect.