@api.global/typedserver
Version:
A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.
47 lines (46 loc) • 1.72 kB
TypeScript
import { type IServerOptions, type ISecurityHeaders, TypedServer } from '../classes.typedserver.js';
import * as plugins from '../plugins.js';
export interface IUtilityWebsiteServerConstructorOptions {
/** Custom route handler to add additional routes */
addCustomRoutes?: (typedserver: TypedServer) => Promise<any>;
/** Application semantic version */
appSemVer?: string;
/** Domain name for the website */
domain: string;
/** Directory to serve static files from */
serveDir: string;
/** RSS feed metadata */
feedMetadata?: IServerOptions['feedMetadata'];
/** Enable/disable CORS (default: true) */
cors?: boolean;
/** Enable/disable SPA fallback (default: true) */
spaFallback?: boolean;
/** Security headers configuration */
securityHeaders?: ISecurityHeaders;
/** Force SSL redirect (default: false) */
forceSsl?: boolean;
/** Port to listen on (default: 3000) */
port?: number;
/** ads.txt entries (only served if configured) */
adsTxt?: string[];
/** Response compression configuration (default: enabled with brotli + gzip) */
compression?: plugins.smartserve.ICompressionConfig | boolean;
}
/**
* the utility website server implements a best practice server for websites
* It supports:
* * live reload
* * serviceworker
* * pwa manifest
*/
export declare class UtilityWebsiteServer {
options: IUtilityWebsiteServerConstructorOptions;
typedserver: TypedServer;
typedrouter: plugins.typedrequest.TypedRouter;
constructor(optionsArg: IUtilityWebsiteServerConstructorOptions);
/**
* Start the website server
*/
start(portArg?: number): Promise<void>;
stop(): Promise<void>;
}