Table of Contents

Class NiteDevServer

Namespace
Nite.Dev
Assembly
Nite.dll

The development server behind /_nite. Source files are compiled on request (one esbuild transform each, cached until the file changes), bare imports resolve through an import map to pre-bundled dependencies, and a file watcher drives hot updates over a WebSocket: React components refresh in place, CSS swaps in place, and anything else reloads the page.

public sealed class NiteDevServer : INiteAssets, IAsyncDisposable
Inheritance
NiteDevServer
Implements
Inherited Members

Constructors

NiteDevServer(NiteProject, HttpClient, ILoggerFactory)

public NiteDevServer(NiteProject project, HttpClient http, ILoggerFactory loggerFactory)

Parameters

project NiteProject
http HttpClient
loggerFactory ILoggerFactory

Properties

IsDevelopment

public bool IsDevelopment { get; }

Property Value

bool

Methods

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

GetHeadAsync(HttpContext)

public ValueTask<NiteHead> GetHeadAsync(HttpContext context)

Parameters

context HttpContext

Returns

ValueTask<NiteHead>

GetHtmlAsync(string, HttpContext)

Renders an HTML entry (such as index.html) with its scripts and styles wired up.

public ValueTask<string> GetHtmlAsync(string page, HttpContext context)

Parameters

page string
context HttpContext

Returns

ValueTask<string>

GetIslandAsync(string, HttpContext)

Resolves an island by name (its path under the islands folder, without extension).

public ValueTask<NiteAsset> GetIslandAsync(string name, HttpContext context)

Parameters

name string
context HttpContext

Returns

ValueTask<NiteAsset>

GetModuleAsync(string, HttpContext)

Resolves an entry module by its path relative to the client root.

public ValueTask<NiteAsset> GetModuleAsync(string source, HttpContext context)

Parameters

source string
context HttpContext

Returns

ValueTask<NiteAsset>

HandleAsync(HttpContext)

Handles a request under /_nite (the prefix is already in PathBase).

public Task HandleAsync(HttpContext context)

Parameters

context HttpContext

Returns

Task

Start(Task?)

Starts installing, scanning and pre-bundling in the background. Safe to call more than once.

public void Start(Task? hostStarted = null)

Parameters

hostStarted Task

Completes when the host has started. Startup waits for it, because telemetry listeners (OpenTelemetry's) subscribe as the host starts and would miss the startup trace otherwise.