@gati-framework/runtime
Version:
Gati runtime execution engine for running handler-based applications
53 lines • 1.6 kB
TypeScript
/**
* @module runtime/loader
* @description Automatic handler discovery and registration
*/
import type { GatiApp } from './app-core.js';
import type { Handler } from './types/handler.js';
/**
* Handler file metadata
*/
export interface HandlerFile {
/** File path */
path: string;
/** Handler function */
handler: Handler;
/** HTTP method (extracted from filename or metadata) */
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
/** Route path (extracted from filename or metadata) */
route?: string;
}
/**
* Discover all handler files in a directory
*
* @param dir - Directory to search (e.g., './src/handlers')
* @returns Array of handler file paths
*
* @example
* ```typescript
* const handlers = await discoverHandlers('./src/handlers');
* // Returns: ['./src/handlers/hello.ts', './src/handlers/users/create.ts']
* ```
*/
export declare function discoverHandlers(dir: string): Promise<string[]>;
/**
* Load and register handlers from a directory
*
* @param app - GatiApp instance
* @param handlersDir - Directory containing handlers (e.g., './src/handlers')
* @param options - Loading options
*
* @example
* ```typescript
* const app = createApp();
* await loadHandlers(app, './src/handlers');
* // All handlers automatically registered
* ```
*/
export declare function loadHandlers(app: GatiApp, handlersDir: string, options?: {
/** Base path for routes (default: '') */
basePath?: string;
/** Enable verbose logging (default: false) */
verbose?: boolean;
}): Promise<void>;
//# sourceMappingURL=loader.d.ts.map