@api.global/typedserver
Version:
A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.
80 lines (79 loc) • 2.22 kB
TypeScript
import * as plugins from './plugins.js';
import * as servertools from './servertools/index.js';
import { type TCompressionMethod } from './servertools/classes.compressor.js';
export interface IServerOptions {
/**
* serve a particular directory
*/
serveDir?: string;
/**
* inject a reload script that takes care of live reloading
*/
injectReload?: boolean;
/**
* enable compression
*/
enableCompression?: boolean;
/**
* choose a preferred compression method
*/
preferredCompressionMethod?: TCompressionMethod;
/**
* watch the serve directory?
*/
watch?: boolean;
cors: boolean;
/**
* a default answer given in case there is no other handler.
* @returns
*/
defaultAnswer?: () => Promise<string>;
/**
* will try to reroute traffic to an ssl connection using headers
*/
forceSsl?: boolean;
/**
* allows serving manifests
*/
manifest?: plugins.smartmanifest.ISmartManifestConstructorOptions;
/**
* the port to listen on
* can be overwritten when actually starting the server
*/
port?: number | string;
publicKey?: string;
privateKey?: string;
sitemap?: boolean;
feed?: boolean;
robots?: boolean;
domain?: string;
/**
* convey information about the app being served
*/
appVersion?: string;
feedMetadata?: plugins.smartfeed.IFeedOptions;
articleGetterFunction?: () => Promise<plugins.tsclass.content.IArticle[]>;
blockWaybackMachine?: boolean;
}
export declare class TypedServer {
options: IServerOptions;
server: servertools.Server;
smartchokInstance: plugins.smartchok.Smartchok;
serveDirHashSubject: plugins.smartrx.rxjs.ReplaySubject<string>;
serveHash: string;
typedsocket: plugins.typedsocket.TypedSocket;
typedrouter: plugins.typedrequest.TypedRouter;
lastReload: number;
ended: boolean;
constructor(optionsArg: IServerOptions);
/**
* inits and starts the server
*/
start(): Promise<void>;
/**
* reloads the page
*/
reload(): Promise<void>;
stop(): Promise<void>;
createServeDirHash(): Promise<void>;
}