@whook/whook
Version:
Build strong and efficient REST web services.
36 lines (35 loc) • 1.73 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';
import { type WhookMain } from '../types/base.js';
export declare const DEFAULT_ROUTES_DEFINITIONS_OPTIONS: WhookRoutesDefinitionsOptions;
export declare const DEFAULT_ROUTE_DEFINITION_FILTER: WhookRouteDefinitionFilter;
export type WhookRouteDefinitionFilter = (definition: WhookRouteDefinition) => boolean;
export interface 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 interface WhookRoutesDefinitionsConfig {
ROUTES_DEFINITIONS_OPTIONS?: WhookRoutesDefinitionsOptions;
ROUTE_DEFINITION_FILTER?: WhookRouteDefinitionFilter;
WHOOK_PLUGINS?: WhookPluginName[];
}
export type WhookRoutesDefinitionsDependencies = WhookRoutesDefinitionsConfig & {
APP_ENV: WhookMain['AppEnv'];
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;