import { Emitter } from './@types/Emitter'; import { BodyDefinition, HeadersDefinition, PathDefinition } from './@types'; import { Route } from './Route'; export type StubbornOptions = { host?: string; defaultHeaders?: HeadersDefinition; }; /** * @example * ```typescript * import { Stubborn } from 'stubborn-ws'; * const sb = new Stubborn(); * * sb.get('/').setResponseBody({ some: 'body' }); * * const res = await got(`${sb.getOrigin()}`, { json: true }); * * expect(res.body).toEqual({ some: 'body' }); * ``` */ export declare class Stubborn implements Emitter { private server; private port; private router; private stubbornOptions; private emitter; constructor(options?: StubbornOptions); /** * Returns the server port. * * If the server is initialized with options.port set to 0 this method * will return the randomly affected port only after the server is started * @returns Listening port or null if the server is not started */ getPort(): number | null; /** * Returns the server origin (http://:) * @returns the server origin */ getOrigin(): string; /** * Remove all routes from the server */ clear(): this; /** * Create and Register a new DELETE route * * @param path Path matching definition */ delete(path: PathDefinition): Route; /** * Create and Register a new GET route * * @param path Path matching definition */ get(path: PathDefinition): Route; /** * Create and Register a new PACH route * * @param path Path matching definition * @param body Request body definition */ patch(path: PathDefinition, body?: BodyDefinition): Route; /** * Create and Register a new POST route * * @param path Path matching definition * @param body Request body definition */ post(path: PathDefinition, body?: BodyDefinition): Route; /** * Create and Register a new PUT route * * @param path Path matching definition * @param body Request body definition */ put(path: PathDefinition, body?: BodyDefinition): Route; /** * Create and Register a new HEAD route * * @param path Path matching definition * @param body Request body definition */ head(path: PathDefinition): Route; /** * Create and Register a new HEAD route * * @param path Path matching definition * @param body Request body definition */ options(path: PathDefinition): Route; /** * Register a new route * * @param route Route a Route object */ addRoute(route: Route): Route; /** * Remove an existing route * * @param route Route a Route object */ removeRoute(route: Route): Route; /** * Start the Stubborn server * @returns Promise object resolved when server is started */ start(port?: number): Promise; /** * Stop the Stubborn server * * @returns Promise object resolved when server is stopped */ stop(): Promise; on(event: symbol, listener: (...args: any[]) => void): this; once(event: symbol, listener: (...args: any[]) => void): this; off(event: symbol, listener: (...args: any[]) => void): this; setMaxListeners(nb: number): this; getMaxListeners(): number; }