@appium/base-driver
Version:
Base driver class for Appium drivers
67 lines • 2.38 kB
TypeScript
import type { Express } from 'express';
import type { Server as HttpServer } from 'node:http';
import type { AppiumServer, ServerArgs, UpdateServerCallback, MethodMap, ExternalDriver, StringRecord } from '@appium/types';
/** Options for {@linkcode RouteConfiguringFunction} */
export interface RouteConfiguringFunctionOpts {
basePath?: string;
extraMethodMap?: MethodMap<ExternalDriver>;
}
/** A function which configures routes */
export type RouteConfiguringFunction = (app: Express, opts?: RouteConfiguringFunctionOpts) => void;
/** Options for {@linkcode server} */
export interface ServerOpts {
routeConfiguringFunction: RouteConfiguringFunction;
port: number;
cliArgs?: Partial<ServerArgs>;
hostname?: string;
allowCors?: boolean;
basePath?: string;
extraMethodMap?: MethodMap<ExternalDriver>;
serverUpdaters?: UpdateServerCallback[];
keepAliveTimeout?: number;
requestTimeout?: number;
}
/** Options for {@linkcode configureServer} */
export interface ConfigureServerOpts {
app: Express;
addRoutes: RouteConfiguringFunction;
allowCors?: boolean;
basePath?: string;
extraMethodMap?: MethodMap<ExternalDriver>;
webSocketsMapping?: StringRecord;
useLegacyUpgradeHandler?: boolean;
}
/** Options for {@linkcode configureHttp} */
export interface ConfigureHttpOpts {
httpServer: HttpServer;
reject: (error?: unknown) => void;
keepAliveTimeout: number;
gracefulShutdownTimeout?: number;
}
/** Options for {@linkcode startServer} */
export interface StartServerOpts {
httpServer: HttpServer;
port: number;
hostname?: string;
keepAliveTimeout: number;
requestTimeout?: number;
}
/**
* @param opts - Server options
* @returns Promise resolving to the Appium server instance
*/
export declare function server(opts: ServerOpts): Promise<AppiumServer>;
/**
* Sets up Express middleware and routes.
*
* @param opts - Configuration options
*/
export declare function configureServer({ app, addRoutes, allowCors, basePath, extraMethodMap, webSocketsMapping, useLegacyUpgradeHandler, }: ConfigureServerOpts): void;
/**
* Normalize base path string (leading slash, no trailing slash).
*
* @param basePath - Raw base path
* @returns Normalized base path
*/
export declare function normalizeBasePath(basePath: string): string;
//# sourceMappingURL=server.d.ts.map