@solid/community-server
Version:
Community Solid Server: an open and modular implementation of the Solid specifications
47 lines (46 loc) • 1.76 kB
TypeScript
import type { HttpHandlerInput } from '../HttpHandler';
import { HttpHandler } from '../HttpHandler';
/**
* Used to link file paths with relative URLs.
* By using a separate class instead of a key/value map it is easier to replace values in Components.js.
*/
export declare class StaticAssetEntry {
readonly relativeUrl: string;
readonly filePath: string;
constructor(relativeUrl: string, filePath: string);
}
/**
* Handler that serves static resources on specific paths.
* Relative file paths are assumed to be relative to the current working directory.
* Relative file paths can be preceded by `@css:`, e.g. `@css:foo/bar`,
* in case they need to be relative to the module root.
* File paths ending in a slash assume the target is a folder and map all of its contents.
*/
export declare class StaticAssetHandler extends HttpHandler {
private readonly mappings;
private readonly pathMatcher;
private readonly expires;
private readonly logger;
/**
* Creates a handler for the provided static resources.
*
* @param assets - A list of {@link StaticAssetEntry}.
* @param baseUrl - The base URL of the server.
* @param options - Specific options.
* @param options.expires - Cache expiration time in seconds.
*/
constructor(assets: StaticAssetEntry[], baseUrl: string, options?: {
expires?: number;
});
/**
* Creates a regular expression that matches the URL paths.
*/
private createPathMatcher;
/**
* Obtains the file path corresponding to the asset URL
*/
private getFilePath;
canHandle({ request }: HttpHandlerInput): Promise<void>;
handle({ request, response }: HttpHandlerInput): Promise<void>;
private getCacheHeaders;
}