@whook/whook
Version:
Build strong and efficient REST web services.
53 lines (52 loc) • 2.57 kB
TypeScript
import { type WhookBodyValidator, type WhookParametersValidators } from '../libs/validation.js';
import { type WhookCoercionOptions } from '../libs/coercion.js';
import { type WhookParsers, type WhookStringifiers, type WhookEncoders, type WhookDecoders } from '../libs/constants.js';
import { type Provider } from 'knifecycle';
import { type WhookHTTPTransactionService } from './httpTransaction.js';
import { type LogService } from 'common-services';
import { type IncomingMessage, type ServerResponse } from 'node:http';
import { type WhookErrorHandler } from '../services/errorHandler.js';
import { type AppEnvVars } from 'application-services';
import { type WhookRouteHandler, WhookRouteConfig } from '../types/routes.js';
import { type WhookSchemaValidatorsService } from './schemaValidators.js';
import { type WhookOpenAPIOperation, type WhookOpenAPI } from '../types/openapi.js';
import { type WhookQueryParser, type WhookQueryParserBuilderService } from './queryParserBuilder.js';
import { type WhookDefinitions } from './DEFINITIONS.js';
export declare const SEARCH_SEPARATOR = "?";
export declare const PATH_SEPARATOR = "/";
export type WhookHandlersService = Record<string, WhookRouteHandler>;
export interface WhookHTTPRouterConfig {
DEBUG_NODE_ENVS?: string[];
BUFFER_LIMIT?: string;
BASE_PATH?: string;
COERCION_OPTIONS?: WhookCoercionOptions;
}
export type WhookHTTPRouterDependencies = WhookHTTPRouterConfig & {
ENV: AppEnvVars;
ROUTES_HANDLERS: WhookHandlersService;
API: WhookOpenAPI;
DEFINITIONS: WhookDefinitions;
PARSERS?: WhookParsers;
STRINGIFIERS?: WhookStringifiers;
DECODERS?: WhookEncoders;
ENCODERS?: WhookDecoders;
queryParserBuilder: WhookQueryParserBuilderService;
log?: LogService;
schemaValidators: WhookSchemaValidatorsService;
httpTransaction: WhookHTTPTransactionService;
errorHandler: WhookErrorHandler;
};
export type WhookHTTPRouterService = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
export type WhookHTTPRouterProvider = Provider<WhookHTTPRouterService>;
export type WhookHTTPRouterDescriptor = {
handler: WhookRouteHandler;
operation: WhookOpenAPIOperation;
config: WhookRouteConfig;
queryParser: WhookQueryParser;
parametersValidators: WhookParametersValidators;
consumableMediaTypes: string[];
produceableMediaTypes: string[];
bodyValidator: WhookBodyValidator;
};
declare const _default: import("knifecycle").ProviderInitializer<WhookHTTPRouterDependencies, WhookHTTPRouterService>;
export default _default;