/// <reference types="node" resolution-mode="require"/>
import { EventEmitter } from 'node:events';
import { Context } from './context.js';
import { HeadersInterface, HeadersObject } from './headers.js';
import { Request as CurveballRequest } from './request.js';
import { Response as CurveballResponse } from './response.js';
/**
 * Package version
 *
 * This line gets automatically replaced during the build phase
 */
export declare const VERSION = "Curveball/dev";
/**
 * The middleware-call Symbol is a special symbol that might exist as a
 * property on an object.
 *
 * If it exists, the object can be used as a middleware.
 */
declare const middlewareCall: unique symbol;
export { middlewareCall };
/**
 * A function that can act as a middleware.
 */
type MiddlewareFunction = (ctx: Context, next: () => Promise<void>) => Promise<void> | void;
type MiddlewareObject = {
    [middlewareCall]: MiddlewareFunction;
};
export type Middleware = MiddlewareFunction | MiddlewareObject;
export declare function invokeMiddlewares(ctx: Context, fns: Middleware[]): Promise<void>;
export default class Application extends EventEmitter {
    middlewares: Middleware[];
    /**
     * Add a middleware to the application.
     *
     * Middlewares are called in the order they are added.
     */
    use(...middleware: Middleware[]): void;
    /**
     * Handles a single request and calls all middleware.
     */
    handle(ctx: Context): Promise<void>;
    /**
     * Executes a request on the server using the standard browser Request and
     * Response objects from the fetch() standard.
     *
     * Node will probably provide these out of the box in Node 18. If you're on
     * an older version, you'll need a polyfill.
     *
     * A use-case for this is allowing test frameworks to make fetch-like
     * requests without actually having to go over the network.
     */
    fetch(request: Request): Promise<Response>;
    /**
     * Does a sub-request based on a Request object, and returns a Response
     * object.
     */
    subRequest(method: string, path: string, headers?: HeadersInterface | HeadersObject, body?: any): Promise<CurveballResponse>;
    subRequest(request: CurveballRequest): Promise<CurveballResponse>;
    private _origin?;
    /**
     * The public base url of the application.
     *
     * This can be auto-detected, but will often be wrong when your server is
     * running behind a reverse proxy or load balancer.
     *
     * To provide this, set the process.env.PUBLIC_URI property.
     */
    get origin(): string;
    set origin(baseUrl: string);
}
