/// //#region src/http.d.ts interface ArkstackMiddlewareConfig { global: TMiddleware[]; before: TMiddleware[]; after: TMiddleware[]; } //#endregion //#region src/kits.d.ts /** * The ArkstackKitDriver class defines the contract for a driver * that can be used with the ArkstackKitContract. */ declare abstract class ArkstackKitDriver { abstract readonly name: string; abstract createApp(): TApp; abstract mountPublicAssets(app: TApp, publicPath: string): PromiseOrValue; abstract bindRouter(app: TApp): PromiseOrValue; abstract applyMiddleware(app: TApp, middleware: ArkstackMiddlewareConfig): PromiseOrValue; abstract applyMiddleware(app: TApp, middleware: TMiddleware): PromiseOrValue; registerErrorHandler(_app: TApp): PromiseOrValue; abstract start(app: TApp, port: number): PromiseOrValue; } /** * The ArkstackKitContract class defines the contract for an * application that uses the ArkstackKitDriver. */ declare abstract class ArkstackKitContract { abstract app: TApp; abstract driver: ArkstackKitDriver; abstract middleware: ArkstackMiddlewareConfig; abstract boot(port: number): Promise; abstract shutdown(): Promise; } //#endregion //#region src/routing.d.ts interface ArkstackRouteListOptions { path?: string; } interface ArkstackRouterContract { bind(app: TApp): PromiseOrValue; list(options?: ArkstackRouteListOptions, app?: TApp): PromiseOrValue; } //#endregion //#region src/Arkstack.d.ts type PromiseOrValue = T | Promise; type ENV = 'development' | 'production' | 'stagging' | 'testing'; type RootDirChangeListener = (dir: string, previousDir: string) => void; declare abstract class Arkstack { static app: unknown; private static appRootDir; protected app: TApp; protected driver: ArkstackKitDriver; abstract getRouter(): ArkstackRouterContract; /** * Boots the application by mounting public assets, binding the * router, applying middleware, and starting the server. * * @param port The numeric port to run the server on * @param defer Set to true to skip server startup */ abstract boot(port: number, defer?: boolean): Promise; /** * Gets the driver application instance. * * @returns */ getAppInstance(): TApp; /** * Gets the static driver application instance. * * @returns */ static getAppInstance(): TApp; /** * Gets the ArkstackKitDriver instance used by the application. * * @returns */ getDriver(): ArkstackKitDriver; /** * Boostrap the app and start up the server * * @param defaultPort start the server with this port if neither PORT nor APP_PORT env variable is set * @param defer Set to true to skip server startup */ startup(defaultPort?: number, defer?: boolean): Promise; /** * Shuts down the application by disconnecting from the database and exiting the process. */ shutdown(): Promise; /** * Get the current app root directory * * @alias getRootDir() * @returns */ static rootDir(): string; /** * Get the current app root directory * * @alias getRootDir() * @returns */ rootDir(): string; /** * Get the current app root directory * * @returns */ static getRootDir(): string; /** * Set the current app root directory * * @param dir The prefered app root directory * @returns */ setRootDir(dir: string): void; /** * Set the current app root directory * * @param dir The prefered app root directory * @returns */ static setRootDir(dir: string): void; } //#endregion export { Arkstack, ArkstackKitContract, ArkstackKitDriver, ArkstackMiddlewareConfig, ArkstackRouteListOptions, ArkstackRouterContract, ENV, PromiseOrValue, RootDirChangeListener };