import { Server } from "@rill/http"; import { Types as T } from "./_types"; declare class Rill { /** The current middleware stack. */ stack: T.Stack; /** Attaches middleware that only run on OPTION requests. */ options: T.MethodShortcut; /** Attaches middleware that only run on HEAD requests. */ head: T.MethodShortcut; /** Attaches middleware that only run on GET requests. */ get: T.MethodShortcut; /** Attaches middleware that only run on PUT requests. */ put: T.MethodShortcut; /** Attaches middleware that only run on POST requests. */ post: T.MethodShortcut; /** Attaches middleware that only run on PATCH requests. */ patch: T.MethodShortcut; /** Attaches middleware that only run on DELETE requests. */ delete: T.MethodShortcut; /** * @description * Creates a universal app that will run middleware for a incoming request. * * @example * const app = Rill() */ constructor(); /** * @description * Takes the current middleware stack, chains it together and * returns a valid handler for a node js style server request. * * @example * const app = Rill() * app.use(...) * require('http').createServer(app.handler()).listen() */ handler(): T.HttpRequestHandler; /** * @description * Creates a node server from the Rill server. * * @example * app.createServer().listen(3000) * * @param tls Optional HTTPS/TLS options (key, cert, etc). */ createServer(tls?: T.TlsOptions): Server; /** * @description * Creates a node server from the current Rill server and starts listening for http requests. * * @example * rill().use(...).listen({ port: 3000 }) * * @param options An object with configuration for binding the server to a port and ip. * @param onListening A function that is called once the server has started. */ listen(options?: T.ListenOptions | T.HttpListenHandler, onListening?: T.HttpListenHandler): Server; /** * @description * Simple syntactic sugar for functions that * wish to modify the current rill instance. * * @example * app.setup(self => { * // Modify the current app. * self.use(...) * self.modified = true * }) * * @param setups A list of functions to run during initialization. */ setup(...setups: T.SetupArg[]): Rill; /** * @description * Append new middleware to the current rill application stack. * * @example * rill.use(fn1, fn2) * * @param middlewares A list of middleware to add to the app. */ use(...middlewares: T.MiddlewareArg[]): Rill; /** * @description * Use middleware at a specific pathname. * * @example * rill.at("/test", (ctx, next) => ...) * * @param pathname The pathname to match before running the middlewares. * @param middlewares A list of middlewares to add to the app. */ at(pathname: string, ...middlewares: T.MiddlewareArg[]): Rill; /** * @description * Use middleware at a specific hostname. * * @example * app.host("test.com", (ctx, next) => ...) * * @param hostname The hostname to match before running the middlewares. * @param middlewares A list of middlewares to add to the app. */ host(hostname: string, ...middlewares: T.MiddlewareArg[]): Rill; } export default Rill; export { Types } from "./_types"; export { default as Context } from "./context"; export { default as Request } from "./request"; export { default as Response } from "./response";