blaizejs 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -297,6 +297,12 @@ interface Router {
297
297
  getRoutes: () => Route[];
298
298
  /** Add a route programmatically */
299
299
  addRoute: (route: Route) => void;
300
+ /** Add multiple routes programmatically with batch processing */
301
+ addRoutes: (routes: Route[]) => {
302
+ added: Route[];
303
+ removed: string[];
304
+ changed: Route[];
305
+ };
300
306
  /** Add a route directory for plugins */
301
307
  addRouteDirectory(directory: string, options?: {
302
308
  prefix?: string;
@@ -306,6 +312,8 @@ interface Router {
306
312
  path: string;
307
313
  sources: string[];
308
314
  }>;
315
+ /** Close watchers and cleanup resources */
316
+ close?: () => Promise<void>;
309
317
  }
310
318
  /**
311
319
  * Route match result
@@ -339,6 +347,10 @@ interface Matcher {
339
347
  method: HttpMethod;
340
348
  params: Record<string, string>;
341
349
  }[];
350
+ /** Remove a route from the matcher (optional for compatibility) */
351
+ remove: (path: string) => void;
352
+ /** Clear all routes from the matcher (optional for compatibility) */
353
+ clear: () => void;
342
354
  }
343
355
  interface ParsedRoute {
344
356
  filePath: string;
@@ -500,6 +512,38 @@ type CreateOptionsRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.Zod
500
512
  OPTIONS: RouteMethodOptions<P, Q, never, R>;
501
513
  path: string;
502
514
  };
515
+ interface FileCache {
516
+ routes: Route[];
517
+ timestamp: number;
518
+ hash: string;
519
+ }
520
+ interface ReloadMetrics {
521
+ fileChanges: number;
522
+ totalReloadTime: number;
523
+ averageReloadTime: number;
524
+ slowReloads: Array<{
525
+ file: string;
526
+ time: number;
527
+ }>;
528
+ }
529
+ interface WatchOptions {
530
+ debounceMs?: number;
531
+ /** Directories to ignore */
532
+ ignore?: string[];
533
+ /** Callback for new routes */
534
+ onRouteAdded?: (filePath: string, routes: Route[]) => void;
535
+ /** Callback for changed routes */
536
+ onRouteChanged?: (filePath: string, routes: Route[]) => void;
537
+ /** Callback for removed routes */
538
+ onRouteRemoved?: (filePath: string, routes: Route[]) => void;
539
+ /** Callback for errors */
540
+ onError?: (error: Error) => void;
541
+ }
542
+ interface RouteRegistry {
543
+ routesByPath: Map<string, Route>;
544
+ routesByFile: Map<string, Set<string>>;
545
+ pathToFile: Map<string, string>;
546
+ }
503
547
 
504
548
  type ExtractParams<T> = T extends RouteMethodOptions<infer P, any, any, any> ? P extends z.ZodType ? Infer<P> : Record<string, string> : never;
505
549
  type ExtractQuery<T> = T extends RouteMethodOptions<any, infer Q, any, any> ? Q extends z.ZodType ? Infer<Q> : Record<string, string | string[] | undefined> : never;
@@ -762,4 +806,4 @@ declare const Blaize: {
762
806
  VERSION: string;
763
807
  };
764
808
 
765
- export { Blaize, type BuildRoutesRegistry, type ClientConfig, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type ErrorHandlerOptions, type ExtractBody, type ExtractMethod, type ExtractParams, type ExtractQuery, type ExtractResponse, type GetContextFn, type Http2Options, type HttpMethod, type Infer, type Matcher, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type NextFunction, type ParsedRoute, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type QueryParams, type RequestArgs, type RequestHandler, type RequestOptions, type RequestParams, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteSchema, type Router, RouterAPI, type RouterOptions, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamOptions, type UnifiedRequest, type UnifiedResponse, type UnknownFunction, VERSION, compose, createDeleteRoute, createGetRoute, createHeadRoute, create$2 as createMiddleware, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPostRoute, createPutRoute, create as createServer, Blaize as default };
809
+ export { Blaize, type BuildRoutesRegistry, type ClientConfig, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type ErrorHandlerOptions, type ExtractBody, type ExtractMethod, type ExtractParams, type ExtractQuery, type ExtractResponse, type FileCache, type GetContextFn, type Http2Options, type HttpMethod, type Infer, type Matcher, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type NextFunction, type ParsedRoute, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type QueryParams, type ReloadMetrics, type RequestArgs, type RequestHandler, type RequestOptions, type RequestParams, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteRegistry, type RouteSchema, type Router, RouterAPI, type RouterOptions, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamOptions, type UnifiedRequest, type UnifiedResponse, type UnknownFunction, VERSION, type WatchOptions, compose, createDeleteRoute, createGetRoute, createHeadRoute, create$2 as createMiddleware, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPostRoute, createPutRoute, create as createServer, Blaize as default };
package/dist/index.d.ts CHANGED
@@ -297,6 +297,12 @@ interface Router {
297
297
  getRoutes: () => Route[];
298
298
  /** Add a route programmatically */
299
299
  addRoute: (route: Route) => void;
300
+ /** Add multiple routes programmatically with batch processing */
301
+ addRoutes: (routes: Route[]) => {
302
+ added: Route[];
303
+ removed: string[];
304
+ changed: Route[];
305
+ };
300
306
  /** Add a route directory for plugins */
301
307
  addRouteDirectory(directory: string, options?: {
302
308
  prefix?: string;
@@ -306,6 +312,8 @@ interface Router {
306
312
  path: string;
307
313
  sources: string[];
308
314
  }>;
315
+ /** Close watchers and cleanup resources */
316
+ close?: () => Promise<void>;
309
317
  }
310
318
  /**
311
319
  * Route match result
@@ -339,6 +347,10 @@ interface Matcher {
339
347
  method: HttpMethod;
340
348
  params: Record<string, string>;
341
349
  }[];
350
+ /** Remove a route from the matcher (optional for compatibility) */
351
+ remove: (path: string) => void;
352
+ /** Clear all routes from the matcher (optional for compatibility) */
353
+ clear: () => void;
342
354
  }
343
355
  interface ParsedRoute {
344
356
  filePath: string;
@@ -500,6 +512,38 @@ type CreateOptionsRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.Zod
500
512
  OPTIONS: RouteMethodOptions<P, Q, never, R>;
501
513
  path: string;
502
514
  };
515
+ interface FileCache {
516
+ routes: Route[];
517
+ timestamp: number;
518
+ hash: string;
519
+ }
520
+ interface ReloadMetrics {
521
+ fileChanges: number;
522
+ totalReloadTime: number;
523
+ averageReloadTime: number;
524
+ slowReloads: Array<{
525
+ file: string;
526
+ time: number;
527
+ }>;
528
+ }
529
+ interface WatchOptions {
530
+ debounceMs?: number;
531
+ /** Directories to ignore */
532
+ ignore?: string[];
533
+ /** Callback for new routes */
534
+ onRouteAdded?: (filePath: string, routes: Route[]) => void;
535
+ /** Callback for changed routes */
536
+ onRouteChanged?: (filePath: string, routes: Route[]) => void;
537
+ /** Callback for removed routes */
538
+ onRouteRemoved?: (filePath: string, routes: Route[]) => void;
539
+ /** Callback for errors */
540
+ onError?: (error: Error) => void;
541
+ }
542
+ interface RouteRegistry {
543
+ routesByPath: Map<string, Route>;
544
+ routesByFile: Map<string, Set<string>>;
545
+ pathToFile: Map<string, string>;
546
+ }
503
547
 
504
548
  type ExtractParams<T> = T extends RouteMethodOptions<infer P, any, any, any> ? P extends z.ZodType ? Infer<P> : Record<string, string> : never;
505
549
  type ExtractQuery<T> = T extends RouteMethodOptions<any, infer Q, any, any> ? Q extends z.ZodType ? Infer<Q> : Record<string, string | string[] | undefined> : never;
@@ -762,4 +806,4 @@ declare const Blaize: {
762
806
  VERSION: string;
763
807
  };
764
808
 
765
- export { Blaize, type BuildRoutesRegistry, type ClientConfig, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type ErrorHandlerOptions, type ExtractBody, type ExtractMethod, type ExtractParams, type ExtractQuery, type ExtractResponse, type GetContextFn, type Http2Options, type HttpMethod, type Infer, type Matcher, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type NextFunction, type ParsedRoute, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type QueryParams, type RequestArgs, type RequestHandler, type RequestOptions, type RequestParams, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteSchema, type Router, RouterAPI, type RouterOptions, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamOptions, type UnifiedRequest, type UnifiedResponse, type UnknownFunction, VERSION, compose, createDeleteRoute, createGetRoute, createHeadRoute, create$2 as createMiddleware, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPostRoute, createPutRoute, create as createServer, Blaize as default };
809
+ export { Blaize, type BuildRoutesRegistry, type ClientConfig, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type ErrorHandlerOptions, type ExtractBody, type ExtractMethod, type ExtractParams, type ExtractQuery, type ExtractResponse, type FileCache, type GetContextFn, type Http2Options, type HttpMethod, type Infer, type Matcher, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type NextFunction, type ParsedRoute, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type QueryParams, type ReloadMetrics, type RequestArgs, type RequestHandler, type RequestOptions, type RequestParams, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteRegistry, type RouteSchema, type Router, RouterAPI, type RouterOptions, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamOptions, type UnifiedRequest, type UnifiedResponse, type UnknownFunction, VERSION, type WatchOptions, compose, createDeleteRoute, createGetRoute, createHeadRoute, create$2 as createMiddleware, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPostRoute, createPutRoute, create as createServer, Blaize as default };