import { FunctionMiddleware } from '@midwayjs/core';
import { Context, NextFunction } from '@midwayjs/koa';
import * as Joi from 'joi';
import { RequestMethod } from '../interface';
export type JoiDefinition = {
    [key: string]: Joi.Schema;
} | Joi.Schema | undefined;
/**
 * 输出joi定义
 */
export type OutputValidation = {
    responseType?: 'json' | 'xml' | 'file' | 'image';
    body?: JoiDefinition;
    headers?: JoiDefinition;
};
/**
 * 校验选项
 */
export type ValidateOptions = {
    type?: 'form' | 'xml' | 'json' | 'multipart';
    header?: JoiDefinition;
    query?: JoiDefinition;
    params?: JoiDefinition;
    body?: JoiDefinition;
};
/**
 * 路由定义
 */
export type RouteSpec = {
    id: string;
    options: {
        [key: string]: any;
    };
    pre?: FunctionMiddleware<Context, NextFunction> | undefined;
    validate: ValidateOptions;
    meta?: any;
    method: RequestMethod;
    path: string;
    handler: FunctionMiddleware<Context, NextFunction>;
    output?: {
        [status: string | number]: OutputValidation;
    } | undefined;
};
/**
 * Joi路由
 */
export default class JoiRouter {
    routes: RouteSpec[];
    router: any;
    use(middleware: FunctionMiddleware<Context, NextFunction>): void;
    /**
     * Return koa middleware
     * @return {Function}
     * @api public
     */
    middleware(): FunctionMiddleware<Context, NextFunction>;
    /**
     * 添加路由
     * @param spec
     */
    addRouter(spec: RouteSpec): void;
    /**
     * 路由前缀
     * @param prefix
     */
    prefix(prefix: any): any;
}
