@whook/whook
Version:
Build strong and efficient REST web services.
37 lines (36 loc) • 1.67 kB
TypeScript
import { type ImporterService, type LogService } from 'common-services';
import { type WhookRouteModule, type WhookRouteDefinition } from '../types/routes.js';
import { type WhookResolvedPluginsService, type WhookPluginName } from './WHOOK_RESOLVED_PLUGINS.js';
export declare const DEFAULT_ROUTES_DEFINITIONS_OPTIONS: WhookRoutesDefinitionsOptions;
export declare const DEFAULT_ROUTE_DEFINITION_FILTER: WhookRouteDefinitionFilter;
export interface WhookRouteDefinitionFilter {
(definition: WhookRouteDefinition): boolean;
}
export type WhookRoutesDefinitionsOptions = {
/** File patterns to ignore */
ignoredFilePatterns?: string[];
/** Pattern to match and pick the handler name in the file name */
fileNamePatterns: [string, ...string[]];
/** Patterns that matches an handler name */
serviceNamePatterns: [string, ...string[]];
};
export type WhookRoutesDefinitionsConfig = {
ROUTES_DEFINITIONS_OPTIONS?: WhookRoutesDefinitionsOptions;
ROUTE_DEFINITION_FILTER?: WhookRouteDefinitionFilter;
WHOOK_PLUGINS?: WhookPluginName[];
};
export type WhookRoutesDefinitionsDependencies = WhookRoutesDefinitionsConfig & {
APP_ENV: string;
WHOOK_RESOLVED_PLUGINS: WhookResolvedPluginsService;
log?: LogService;
importer: ImporterService<WhookRouteModule>;
readDir?: (path: URL) => Promise<string[]>;
};
export type WhookRoutesDefinitionsService = Record<string, {
url: string;
name: string;
pluginName: WhookPluginName;
module: WhookRouteModule;
}>;
declare const _default: import("knifecycle").ServiceInitializer<WhookRoutesDefinitionsDependencies, WhookRoutesDefinitionsService>;
export default _default;