Type of custom extensions added to the context
Creates a new Kito server instance.
Type of custom extensions added to the context
Optionaloptions: ServerOptionsServer configuration options
Optionalport?: numberOptionalhost?: stringOptionalunixSocket?: stringOptionaltrustProxy?: booleanOptionalmaxRequestSize?: numberOptionaltimeout?: numberOptionalreusePort?: booleanRegisters a global middleware that runs for all routes in this router.
Middleware function or definition
The router instance for chaining
Registers a GET route.
Registers a GET route.
Registers a GET route.
Registers a GET route.
Registers a POST route.
Registers a POST route.
Registers a POST route.
Registers a POST route.
Registers a PUT route.
Registers a PUT route.
Registers a PUT route.
Registers a PUT route.
Registers a DELETE route.
Registers a DELETE route.
Registers a DELETE route.
Registers a DELETE route.
Registers a PATCH route.
Registers a PATCH route.
Registers a PATCH route.
Registers a PATCH route.
Registers a HEAD route.
Registers a HEAD route.
Registers a HEAD route.
Registers a HEAD route.
Registers an OPTIONS route.
Registers an OPTIONS route.
Registers an OPTIONS route.
Registers an OPTIONS route.
Creates a route builder for chaining multiple HTTP methods on the same path.
Base path for all routes in the chain
OptionalrouteMiddlewares: MiddlewareDefinition | MiddlewareDefinition[]Optional middleware to apply to all routes in the chain
Route chain builder
Extends the request context with custom properties or methods.
Type of the new extensions
Function that adds extensions to the context
A new server instance with extended context type
Mounts a sub-router at the specified path.
Base path for the sub-router
Router instance to mount
The router instance for chaining
Starts the server.
You can call listen in multiple ways:
1. Using a port (classic usage)
app.listen(3000);
app.listen(3000, "0.0.0.0");
app.listen(3000, () => console.log("Ready"));
app.listen(3000, "0.0.0.0", () => console.log("Ready"));
2. Using an options object
app.listen({
port: 3000,
host: "0.0.0.0",
});
3. Listening on a Unix Domain Socket
app.listen({
unixSocket: "/tmp/kito.sock",
});
When unixSocket is provided:
port and host are ignoredYou may also pass a callback as the last argument in all forms.
OptionalportOrCallbackOrOptions: number | ServerOptions | (() => void)Port number, callback, or a full ServerOptions object.
OptionalhostOrCallback: string | (() => void)Hostname or callback.
OptionalmaybeCallback: () => voidOptional callback executed once the server starts.
The resolved server configuration.
Closes the server and stops accepting new connections.
Main server class for Kito framework. Extends Router to provide HTTP routing, middleware support, and adds server-specific functionality.
Example