honest-node 1.0.0

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.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +277 -0
  3. package/dist/app.d.ts +1 -0
  4. package/dist/app.js +36 -0
  5. package/dist/application/plugin-entries.d.ts +13 -0
  6. package/dist/application/plugin-entries.js +38 -0
  7. package/dist/application/startup-guide.d.ts +4 -0
  8. package/dist/application/startup-guide.js +53 -0
  9. package/dist/application-context.d.ts +13 -0
  10. package/dist/application-context.js +22 -0
  11. package/dist/application.d.ts +34 -0
  12. package/dist/application.js +224 -0
  13. package/dist/components/index.d.ts +1 -0
  14. package/dist/components/index.js +1 -0
  15. package/dist/components/layout.component.d.ts +31 -0
  16. package/dist/components/layout.component.js +94 -0
  17. package/dist/constants/index.d.ts +2 -0
  18. package/dist/constants/index.js +2 -0
  19. package/dist/constants/pipeline.constants.d.ts +6 -0
  20. package/dist/constants/pipeline.constants.js +6 -0
  21. package/dist/constants/version.constants.d.ts +5 -0
  22. package/dist/constants/version.constants.js +5 -0
  23. package/dist/decorators/controller.decorator.d.ts +9 -0
  24. package/dist/decorators/controller.decorator.js +16 -0
  25. package/dist/decorators/http-method.decorator.d.ts +43 -0
  26. package/dist/decorators/http-method.decorator.js +44 -0
  27. package/dist/decorators/index.d.ts +11 -0
  28. package/dist/decorators/index.js +11 -0
  29. package/dist/decorators/module.decorator.d.ts +8 -0
  30. package/dist/decorators/module.decorator.js +12 -0
  31. package/dist/decorators/mvc.decorator.d.ts +26 -0
  32. package/dist/decorators/mvc.decorator.js +36 -0
  33. package/dist/decorators/parameter.decorator.d.ts +41 -0
  34. package/dist/decorators/parameter.decorator.js +59 -0
  35. package/dist/decorators/service.decorator.d.ts +6 -0
  36. package/dist/decorators/service.decorator.js +11 -0
  37. package/dist/decorators/use-component.decorator.d.ts +10 -0
  38. package/dist/decorators/use-component.decorator.js +19 -0
  39. package/dist/decorators/use-filters.decorator.d.ts +8 -0
  40. package/dist/decorators/use-filters.decorator.js +17 -0
  41. package/dist/decorators/use-guards.decorator.d.ts +9 -0
  42. package/dist/decorators/use-guards.decorator.js +18 -0
  43. package/dist/decorators/use-middleware.decorator.d.ts +9 -0
  44. package/dist/decorators/use-middleware.decorator.js +18 -0
  45. package/dist/decorators/use-pipes.decorator.d.ts +9 -0
  46. package/dist/decorators/use-pipes.decorator.js +18 -0
  47. package/dist/di/container.d.ts +34 -0
  48. package/dist/di/container.js +114 -0
  49. package/dist/di/index.d.ts +1 -0
  50. package/dist/di/index.js +1 -0
  51. package/dist/errors/framework.error.d.ts +19 -0
  52. package/dist/errors/framework.error.js +23 -0
  53. package/dist/errors/index.d.ts +1 -0
  54. package/dist/errors/index.js +1 -0
  55. package/dist/handlers/error.handler.d.ts +28 -0
  56. package/dist/handlers/error.handler.js +17 -0
  57. package/dist/handlers/index.d.ts +2 -0
  58. package/dist/handlers/index.js +2 -0
  59. package/dist/handlers/not-found.handler.d.ts +14 -0
  60. package/dist/handlers/not-found.handler.js +17 -0
  61. package/dist/helpers/create-error-response.helper.d.ts +25 -0
  62. package/dist/helpers/create-error-response.helper.js +90 -0
  63. package/dist/helpers/create-http-method-decorator.helper.d.ts +16 -0
  64. package/dist/helpers/create-http-method-decorator.helper.js +30 -0
  65. package/dist/helpers/create-param-decorator.helper.d.ts +16 -0
  66. package/dist/helpers/create-param-decorator.helper.js +60 -0
  67. package/dist/helpers/index.d.ts +3 -0
  68. package/dist/helpers/index.js +3 -0
  69. package/dist/index.d.ts +16 -0
  70. package/dist/index.js +16 -0
  71. package/dist/interfaces/application-context.interface.d.ts +35 -0
  72. package/dist/interfaces/application-context.interface.js +1 -0
  73. package/dist/interfaces/controller-options.interface.d.ts +17 -0
  74. package/dist/interfaces/controller-options.interface.js +1 -0
  75. package/dist/interfaces/di-container.interface.d.ts +35 -0
  76. package/dist/interfaces/di-container.interface.js +1 -0
  77. package/dist/interfaces/error-response.interface.d.ts +13 -0
  78. package/dist/interfaces/error-response.interface.js +1 -0
  79. package/dist/interfaces/filter.interface.d.ts +20 -0
  80. package/dist/interfaces/filter.interface.js +1 -0
  81. package/dist/interfaces/guard.interface.d.ts +21 -0
  82. package/dist/interfaces/guard.interface.js +1 -0
  83. package/dist/interfaces/handler-invocation.interface.d.ts +10 -0
  84. package/dist/interfaces/handler-invocation.interface.js +1 -0
  85. package/dist/interfaces/honest-options.interface.d.ts +121 -0
  86. package/dist/interfaces/honest-options.interface.js +1 -0
  87. package/dist/interfaces/http-method-options.interface.d.ts +38 -0
  88. package/dist/interfaces/http-method-options.interface.js +1 -0
  89. package/dist/interfaces/index.d.ts +21 -0
  90. package/dist/interfaces/index.js +21 -0
  91. package/dist/interfaces/logger.interface.d.ts +23 -0
  92. package/dist/interfaces/logger.interface.js +1 -0
  93. package/dist/interfaces/metadata-repository.interface.d.ts +30 -0
  94. package/dist/interfaces/metadata-repository.interface.js +1 -0
  95. package/dist/interfaces/middleware.interface.d.ts +22 -0
  96. package/dist/interfaces/middleware.interface.js +1 -0
  97. package/dist/interfaces/module-options.interface.d.ts +18 -0
  98. package/dist/interfaces/module-options.interface.js +1 -0
  99. package/dist/interfaces/parameter-metadata.interface.d.ts +27 -0
  100. package/dist/interfaces/parameter-metadata.interface.js +1 -0
  101. package/dist/interfaces/parameter-resolution.interface.d.ts +14 -0
  102. package/dist/interfaces/parameter-resolution.interface.js +1 -0
  103. package/dist/interfaces/pipe.interface.d.ts +37 -0
  104. package/dist/interfaces/pipe.interface.js +1 -0
  105. package/dist/interfaces/pipeline-context.interface.d.ts +9 -0
  106. package/dist/interfaces/pipeline-context.interface.js +1 -0
  107. package/dist/interfaces/plugin.interface.d.ts +74 -0
  108. package/dist/interfaces/plugin.interface.js +1 -0
  109. package/dist/interfaces/route-definition.interface.d.ts +51 -0
  110. package/dist/interfaces/route-definition.interface.js +1 -0
  111. package/dist/interfaces/route-info.interface.d.ts +42 -0
  112. package/dist/interfaces/route-info.interface.js +1 -0
  113. package/dist/interfaces/service-registry.interface.d.ts +7 -0
  114. package/dist/interfaces/service-registry.interface.js +1 -0
  115. package/dist/loggers/console.logger.d.ts +7 -0
  116. package/dist/loggers/console.logger.js +21 -0
  117. package/dist/loggers/index.d.ts +2 -0
  118. package/dist/loggers/index.js +2 -0
  119. package/dist/loggers/noop.logger.d.ts +7 -0
  120. package/dist/loggers/noop.logger.js +8 -0
  121. package/dist/managers/component.manager.d.ts +48 -0
  122. package/dist/managers/component.manager.js +210 -0
  123. package/dist/managers/handler.invoker.d.ts +7 -0
  124. package/dist/managers/handler.invoker.js +37 -0
  125. package/dist/managers/index.d.ts +5 -0
  126. package/dist/managers/index.js +5 -0
  127. package/dist/managers/parameter.resolver.d.ts +13 -0
  128. package/dist/managers/parameter.resolver.js +58 -0
  129. package/dist/managers/pipeline.executor.d.ts +28 -0
  130. package/dist/managers/pipeline.executor.js +71 -0
  131. package/dist/managers/route.manager.d.ts +36 -0
  132. package/dist/managers/route.manager.js +149 -0
  133. package/dist/registries/index.d.ts +4 -0
  134. package/dist/registries/index.js +4 -0
  135. package/dist/registries/metadata.registry.d.ts +163 -0
  136. package/dist/registries/metadata.registry.js +250 -0
  137. package/dist/registries/metadata.repository.d.ts +30 -0
  138. package/dist/registries/metadata.repository.js +151 -0
  139. package/dist/registries/route.registry.d.ts +16 -0
  140. package/dist/registries/route.registry.js +46 -0
  141. package/dist/registries/service.registry.d.ts +8 -0
  142. package/dist/registries/service.registry.js +9 -0
  143. package/dist/testing/create-controller-test-application.d.ts +5 -0
  144. package/dist/testing/create-controller-test-application.js +11 -0
  145. package/dist/testing/create-service-test-container.d.ts +5 -0
  146. package/dist/testing/create-service-test-container.js +31 -0
  147. package/dist/testing/create-test-application.d.ts +5 -0
  148. package/dist/testing/create-test-application.js +20 -0
  149. package/dist/testing/create-testing-module.d.ts +6 -0
  150. package/dist/testing/create-testing-module.js +13 -0
  151. package/dist/testing/fixtures/application-test-fixtures.d.ts +17 -0
  152. package/dist/testing/fixtures/application-test-fixtures.js +230 -0
  153. package/dist/testing/index.d.ts +5 -0
  154. package/dist/testing/index.js +5 -0
  155. package/dist/testing/testing.interface.d.ts +96 -0
  156. package/dist/testing/testing.interface.js +1 -0
  157. package/dist/types/constructor.type.d.ts +12 -0
  158. package/dist/types/constructor.type.js +1 -0
  159. package/dist/types/index.d.ts +1 -0
  160. package/dist/types/index.js +1 -0
  161. package/dist/utils/common.util.d.ts +117 -0
  162. package/dist/utils/common.util.js +140 -0
  163. package/dist/utils/index.d.ts +1 -0
  164. package/dist/utils/index.js +1 -0
  165. package/package.json +42 -0
@@ -0,0 +1,30 @@
1
+ import { MetadataRegistry } from '../registries';
2
+ /**
3
+ * Creates a decorator factory for HTTP method handlers
4
+ * @param method - The HTTP method type (GET, POST, PUT, etc.)
5
+ * @returns A method decorator factory that accepts a path and options
6
+ * @example
7
+ * ```ts
8
+ * const Get = createHttpMethodDecorator(HttpMethod.GET);
9
+ *
10
+ * class Controller {
11
+ * @Get('/users')
12
+ * getUsers() { }
13
+ * }
14
+ * ```
15
+ */
16
+ export function createHttpMethodDecorator(method) {
17
+ return (path = '', options = {}) => {
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ return (target, propertyKey, descriptor) => {
20
+ const controllerClass = target.constructor;
21
+ MetadataRegistry.addRoute(controllerClass, {
22
+ path,
23
+ method,
24
+ handlerName: propertyKey,
25
+ version: options.version,
26
+ prefix: options.prefix
27
+ });
28
+ };
29
+ };
30
+ }
@@ -0,0 +1,16 @@
1
+ import type { Context } from 'hono';
2
+ /**
3
+ * Creates a parameter decorator factory for route handlers
4
+ * @template T - The type of the parameter value after transformation
5
+ * @param type - The type identifier for the parameter
6
+ * @param factory - Optional function to transform the parameter value
7
+ * @returns A parameter decorator function that registers parameter metadata
8
+ * @example
9
+ * ```ts
10
+ * const Body = createParamDecorator('body', async (data, ctx) => {
11
+ * const body = await ctx.req.json();
12
+ * return data ? body[data] : body;
13
+ * });
14
+ * ```
15
+ */
16
+ export declare function createParamDecorator<T = unknown>(type: string, factory?: (data: unknown, ctx: Context) => T | Promise<T>): (data?: unknown) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
@@ -0,0 +1,60 @@
1
+ import { MetadataRegistry } from '../registries';
2
+ /**
3
+ * Creates a parameter decorator factory for route handlers
4
+ * @template T - The type of the parameter value after transformation
5
+ * @param type - The type identifier for the parameter
6
+ * @param factory - Optional function to transform the parameter value
7
+ * @returns A parameter decorator function that registers parameter metadata
8
+ * @example
9
+ * ```ts
10
+ * const Body = createParamDecorator('body', async (data, ctx) => {
11
+ * const body = await ctx.req.json();
12
+ * return data ? body[data] : body;
13
+ * });
14
+ * ```
15
+ */
16
+ export function createParamDecorator(type, factory) {
17
+ const fallbackFactory = (data, ctx) => {
18
+ // Safe default when a custom decorator doesn't provide a factory.
19
+ // Returning context keeps the value usable and avoids hard runtime crashes.
20
+ if (data === undefined) {
21
+ return ctx;
22
+ }
23
+ return ctx.get(String(data));
24
+ };
25
+ return (data) => {
26
+ // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
27
+ return (target, propertyKey, parameterIndex) => {
28
+ const controllerClass = target.constructor;
29
+ // Initialize parameters map for the controller if not exists
30
+ if (!MetadataRegistry.getParameters(controllerClass).size) {
31
+ MetadataRegistry.setParameterMap(controllerClass, new Map());
32
+ }
33
+ const parametersMap = MetadataRegistry.getParameters(controllerClass);
34
+ // Initialize parameter metadata array for the method if not exists
35
+ if (!parametersMap.has(propertyKey)) {
36
+ parametersMap.set(propertyKey, []);
37
+ }
38
+ // Get the parameter type from the method signature using reflect-metadata
39
+ const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey);
40
+ const metatype = paramTypes?.[parameterIndex];
41
+ // Add parameter metadata
42
+ const parameters = parametersMap.get(propertyKey);
43
+ parameters.push({
44
+ index: parameterIndex,
45
+ name: type,
46
+ data,
47
+ factory: (factory || fallbackFactory),
48
+ metatype
49
+ });
50
+ // If it's a context parameter, track its index
51
+ if (type === 'context') {
52
+ if (!MetadataRegistry.getContextIndices(controllerClass).size) {
53
+ MetadataRegistry.setContextIndices(controllerClass, new Map());
54
+ }
55
+ const contextIndices = MetadataRegistry.getContextIndices(controllerClass);
56
+ contextIndices.set(propertyKey, parameterIndex);
57
+ }
58
+ };
59
+ };
60
+ }
@@ -0,0 +1,3 @@
1
+ export * from './create-error-response.helper';
2
+ export * from './create-http-method-decorator.helper';
3
+ export * from './create-param-decorator.helper';
@@ -0,0 +1,3 @@
1
+ export * from './create-error-response.helper';
2
+ export * from './create-http-method-decorator.helper';
3
+ export * from './create-param-decorator.helper';
@@ -0,0 +1,16 @@
1
+ import 'reflect-metadata';
2
+ export * from './application';
3
+ export * from './application-context';
4
+ export * from './components';
5
+ export * from './constants';
6
+ export * from './decorators';
7
+ export * from './loggers';
8
+ export * from './di';
9
+ export * from './errors';
10
+ export * from './handlers';
11
+ export * from './helpers';
12
+ export * from './interfaces';
13
+ export * from './registries';
14
+ export * from './testing';
15
+ export * from './types';
16
+ export * from './utils';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import 'reflect-metadata';
2
+ export * from './application';
3
+ export * from './application-context';
4
+ export * from './components';
5
+ export * from './constants';
6
+ export * from './decorators';
7
+ export * from './loggers';
8
+ export * from './di';
9
+ export * from './errors';
10
+ export * from './handlers';
11
+ export * from './helpers';
12
+ export * from './interfaces';
13
+ export * from './registries';
14
+ export * from './testing';
15
+ export * from './types';
16
+ export * from './utils';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * App-level registry where your application can publish and read pipeline data by key.
3
+ * Available to bootstrap code, services, and any code with access to `app`.
4
+ * Enables composition without hard coupling: producers and consumers use namespaced keys.
5
+ */
6
+ export interface IApplicationContext {
7
+ /**
8
+ * Get a value by key. Caller provides type for type safety.
9
+ * @param key - Namespaced registry key (e.g. 'app.config', 'openapi.spec')
10
+ * @returns The value or undefined if not set
11
+ */
12
+ get<T>(key: string): T | undefined;
13
+ /**
14
+ * Set a value by key.
15
+ * @param key - Namespaced registry key
16
+ * @param value - Value to store
17
+ */
18
+ set<T>(key: string, value: T): void;
19
+ /**
20
+ * Check if a key is present.
21
+ * @param key - Registry key
22
+ * @returns true if the key exists
23
+ */
24
+ has(key: string): boolean;
25
+ /**
26
+ * Remove a key and its value.
27
+ * @param key - Registry key
28
+ * @returns true if the key existed and was removed
29
+ */
30
+ delete(key: string): boolean;
31
+ /**
32
+ * Iterate over all registered keys.
33
+ */
34
+ keys(): IterableIterator<string>;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { VERSION_NEUTRAL } from '../constants';
2
+ /**
3
+ * Interface for controller configuration options
4
+ */
5
+ export interface ControllerOptions {
6
+ /**
7
+ * API prefix for this controller's routes, overrides global prefix
8
+ */
9
+ prefix?: string | null;
10
+ /**
11
+ * API version for this controller's routes (e.g. 1 becomes /v1), overrides global version
12
+ * Set to null to explicitly opt out of versioning even when global version is set
13
+ * Set to VERSION_NEUTRAL to make routes accessible both with and without version prefix
14
+ * Set to an array of numbers to make routes available at multiple versions
15
+ */
16
+ version?: number | null | typeof VERSION_NEUTRAL | number[];
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import type { Constructor } from '../types';
2
+ /**
3
+ * Interface for dependency injection containers
4
+ * Defines the contract that DI containers must implement to work with the Honest framework
5
+ * Handles the creation and management of dependency instances
6
+ */
7
+ export interface DiContainer {
8
+ /**
9
+ * Resolves a dependency from the container
10
+ * Creates a new instance or returns an existing one based on the container's configuration
11
+ * @param target - The class constructor to resolve
12
+ * @returns An instance of the requested class with all dependencies injected
13
+ * @throws {Error} If the dependency cannot be resolved
14
+ */
15
+ resolve<T>(target: Constructor<T>): T;
16
+ /**
17
+ * Registers a pre-created instance in the container
18
+ * Used for singleton instances or mocks in testing
19
+ * @param target - The class constructor to register the instance for
20
+ * @param instance - The pre-created instance to use
21
+ * @throws {Error} If registration fails
22
+ */
23
+ register<T>(target: Constructor<T>, instance: T): void;
24
+ /**
25
+ * Checks whether the container already holds an instance for the given class
26
+ * @param target - The class constructor to check
27
+ * @returns true if an instance has been resolved or registered
28
+ */
29
+ has<T>(target: Constructor<T>): boolean;
30
+ /**
31
+ * Removes all cached instances from the container
32
+ * Useful for resetting state between tests
33
+ */
34
+ clear(): void;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export interface ErrorResponse {
2
+ status: number;
3
+ message: string;
4
+ timestamp: string;
5
+ path: string;
6
+ requestId?: string;
7
+ code?: string;
8
+ details?: Record<string, any>;
9
+ errors?: Array<{
10
+ property: string;
11
+ constraints: Record<string, string>;
12
+ }>;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { Context } from 'hono';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Interface for exception filters
5
+ * Filters handle and transform exceptions thrown during request processing
6
+ */
7
+ export interface IFilter {
8
+ /**
9
+ * Method to catch and handle exceptions
10
+ * @param exception - The exception that was thrown
11
+ * @param context - The Hono context object
12
+ * @returns A Response object or undefined if the exception should be passed to the next filter
13
+ */
14
+ catch(exception: Error, context: Context): Promise<Response | undefined> | Response | undefined;
15
+ }
16
+ /**
17
+ * Type for exception filters
18
+ * Can be either a class implementing IFilter or an instance of IFilter
19
+ */
20
+ export type FilterType = Constructor<IFilter> | IFilter;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { Constructor } from '../types';
2
+ import type { Context } from 'hono';
3
+ /**
4
+ * Interface defining a guard.
5
+ * Guards determine whether a request should be handled by the route handler or not.
6
+ */
7
+ export interface IGuard {
8
+ /**
9
+ * Method to implement the guard logic.
10
+ * Return true to allow the request to proceed, false to deny.
11
+ *
12
+ * @param context - The Hono context object
13
+ * @returns A boolean or Promise<boolean> indicating if the request is allowed
14
+ */
15
+ canActivate(context: Context): boolean | Promise<boolean>;
16
+ }
17
+ /**
18
+ * Type for guard classes
19
+ * Can be either a constructor of IGuard or an instance of IGuard
20
+ */
21
+ export type GuardType = Constructor<IGuard> | IGuard;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { Context } from 'hono';
2
+ /**
3
+ * Input contract for invoking route handlers and mapping results to HTTP responses.
4
+ */
5
+ export interface HandlerInvocationInput {
6
+ handler: (...args: unknown[]) => Promise<unknown> | unknown;
7
+ args: unknown[];
8
+ context: Context;
9
+ contextIndex?: number;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,121 @@
1
+ import type { Context } from 'hono';
2
+ import type { VERSION_NEUTRAL } from '../constants';
3
+ import type { FilterType, GuardType, ILogger, MiddlewareType, PipeType, PluginEntry } from '../interfaces';
4
+ import type { DiContainer } from './di-container.interface';
5
+ /**
6
+ * Options for configuring the Honest application
7
+ */
8
+ export interface HonestOptions {
9
+ /**
10
+ * Emit actionable startup guidance when initialization fails.
11
+ * - `true` enables concise hints
12
+ * - object form enables verbose hints with additional context
13
+ */
14
+ startupGuide?: boolean | {
15
+ verbose?: boolean;
16
+ };
17
+ /**
18
+ * Enable debug logging for startup diagnostics.
19
+ * - `true` enables all debug logs
20
+ * - object form enables specific categories
21
+ */
22
+ debug?: boolean | {
23
+ routes?: boolean;
24
+ plugins?: boolean;
25
+ pipeline?: boolean;
26
+ di?: boolean;
27
+ startup?: boolean;
28
+ };
29
+ /**
30
+ * Optional logger for structured framework events.
31
+ */
32
+ logger?: ILogger;
33
+ /**
34
+ * Optional strict-mode checks for startup validation.
35
+ */
36
+ strict?: {
37
+ /**
38
+ * When enabled, startup fails if no routes were registered.
39
+ */
40
+ requireRoutes?: boolean;
41
+ };
42
+ /**
43
+ * Optional warnings for unstable/deprecated behavior.
44
+ */
45
+ deprecations?: {
46
+ /**
47
+ * Print pre-v1 instability warning during startup.
48
+ */
49
+ printPreV1Warning?: boolean;
50
+ };
51
+ /**
52
+ * Container instance for dependency injection
53
+ */
54
+ container?: DiContainer;
55
+ /**
56
+ * Hono-specific options
57
+ */
58
+ hono?: {
59
+ /**
60
+ * Whether to use strict matching for routes
61
+ */
62
+ strict?: boolean;
63
+ /**
64
+ * Custom router to use
65
+ */
66
+ router?: any;
67
+ /**
68
+ * Function to extract path from request
69
+ */
70
+ getPath?: (request: Request, options?: any) => string;
71
+ };
72
+ /**
73
+ * Global routing options
74
+ */
75
+ routing?: {
76
+ /**
77
+ * Global API prefix to apply to all routes (e.g. /api)
78
+ */
79
+ prefix?: string;
80
+ /**
81
+ * Global API version to apply to all routes (e.g. 1 becomes /v1)
82
+ * Set to VERSION_NEUTRAL to make routes accessible both with and without version prefix
83
+ * Set to an array of numbers to make routes available at multiple versions
84
+ */
85
+ version?: number | typeof VERSION_NEUTRAL | number[];
86
+ };
87
+ /**
88
+ * Global components to apply to all routes
89
+ */
90
+ components?: {
91
+ /**
92
+ * Global middleware to apply to all routes
93
+ */
94
+ middleware?: MiddlewareType[];
95
+ /**
96
+ * Global guards to apply to all routes
97
+ */
98
+ guards?: GuardType[];
99
+ /**
100
+ * Global pipes to apply to all routes
101
+ */
102
+ pipes?: PipeType[];
103
+ /**
104
+ * Global exception filters to apply to all routes
105
+ */
106
+ filters?: FilterType[];
107
+ };
108
+ /**
109
+ * Plugins for extending the application functionality.
110
+ * Each entry can be a plain plugin or an object with plugin and optional pre/post processors.
111
+ */
112
+ plugins?: PluginEntry[];
113
+ /**
114
+ * Default exception handler to use when no filter matches
115
+ */
116
+ onError?: (error: unknown, context: Context) => Response | Promise<Response>;
117
+ /**
118
+ * Default not found handler for routes that don't match any pattern
119
+ */
120
+ notFound?: (context: Context) => Response | Promise<Response>;
121
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { VERSION_NEUTRAL } from '../constants';
2
+ /**
3
+ * Options for HTTP method decorators (@Get, @Post, @Put, @Delete, etc.)
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * @Get('users', { prefix: 'api', version: 2 })
8
+ * getUsers() {
9
+ * // ...
10
+ * }
11
+ * ```
12
+ */
13
+ export interface HttpMethodOptions {
14
+ /**
15
+ * Optional prefix for this specific route, overrides controller and global prefix.
16
+ * Set to null to explicitly remove any prefix for this route.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * @Get('users', { prefix: 'api' }) // -> /api/users
21
+ * @Get('users', { prefix: null }) // -> /users (no prefix)
22
+ * @Get('users', { prefix: 'v2/api' }) // -> /v2/api/users
23
+ * ```
24
+ */
25
+ prefix?: string | null;
26
+ /**
27
+ * API version for this specific route, overrides controller and global version.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * @Get('users', { version: 1 }) // -> /v1/users
32
+ * @Get('users', { version: null }) // -> /users (no version)
33
+ * @Get('users', { version: VERSION_NEUTRAL }) // -> Both /users and /v1/users
34
+ * @Get('users', { version: [1, 2] }) // -> Both /v1/users and /v2/users
35
+ * ```
36
+ */
37
+ version?: number | null | typeof VERSION_NEUTRAL | number[];
38
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ export * from './application-context.interface';
2
+ export * from './controller-options.interface';
3
+ export * from './di-container.interface';
4
+ export * from './logger.interface';
5
+ export * from './error-response.interface';
6
+ export * from './filter.interface';
7
+ export * from './guard.interface';
8
+ export * from './handler-invocation.interface';
9
+ export * from './honest-options.interface';
10
+ export * from './http-method-options.interface';
11
+ export * from './metadata-repository.interface';
12
+ export * from './middleware.interface';
13
+ export * from './module-options.interface';
14
+ export * from './parameter-metadata.interface';
15
+ export * from './parameter-resolution.interface';
16
+ export * from './pipeline-context.interface';
17
+ export * from './pipe.interface';
18
+ export * from './plugin.interface';
19
+ export * from './route-definition.interface';
20
+ export * from './route-info.interface';
21
+ export * from './service-registry.interface';
@@ -0,0 +1,21 @@
1
+ export * from './application-context.interface';
2
+ export * from './controller-options.interface';
3
+ export * from './di-container.interface';
4
+ export * from './logger.interface';
5
+ export * from './error-response.interface';
6
+ export * from './filter.interface';
7
+ export * from './guard.interface';
8
+ export * from './handler-invocation.interface';
9
+ export * from './honest-options.interface';
10
+ export * from './http-method-options.interface';
11
+ export * from './metadata-repository.interface';
12
+ export * from './middleware.interface';
13
+ export * from './module-options.interface';
14
+ export * from './parameter-metadata.interface';
15
+ export * from './parameter-resolution.interface';
16
+ export * from './pipeline-context.interface';
17
+ export * from './pipe.interface';
18
+ export * from './plugin.interface';
19
+ export * from './route-definition.interface';
20
+ export * from './route-info.interface';
21
+ export * from './service-registry.interface';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Log level.
3
+ */
4
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
5
+ /**
6
+ * Log category used to filter or route events.
7
+ */
8
+ export type LogCategory = 'startup' | 'routes' | 'plugins' | 'deprecations' | 'pipeline' | 'di' | 'errors';
9
+ /**
10
+ * Structured log event emitted by Honest runtime components.
11
+ */
12
+ export interface LogEvent {
13
+ level: LogLevel;
14
+ category: LogCategory;
15
+ message: string;
16
+ details?: Record<string, unknown>;
17
+ }
18
+ /**
19
+ * Logger contract.
20
+ */
21
+ export interface ILogger {
22
+ emit(event: LogEvent): void;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { ControllerOptions } from './controller-options.interface';
2
+ import type { FilterType } from './filter.interface';
3
+ import type { GuardType } from './guard.interface';
4
+ import type { MiddlewareType } from './middleware.interface';
5
+ import type { ModuleOptions } from './module-options.interface';
6
+ import type { ParameterMetadata } from './parameter-metadata.interface';
7
+ import type { PipeType } from './pipe.interface';
8
+ import type { RouteDefinition } from './route-definition.interface';
9
+ import type { Constructor } from '../types';
10
+ export type MetadataComponentType = 'middleware' | 'guard' | 'pipe' | 'filter';
11
+ export interface MetadataComponentTypeMap {
12
+ middleware: MiddlewareType;
13
+ guard: GuardType;
14
+ pipe: PipeType;
15
+ filter: FilterType;
16
+ }
17
+ /**
18
+ * Runtime metadata access contract used by framework managers.
19
+ */
20
+ export interface IMetadataRepository {
21
+ hasController(controller: Constructor): boolean;
22
+ getControllerPath(controller: Constructor): string;
23
+ getControllerOptions(controller: Constructor): ControllerOptions;
24
+ getRoutes(controller: Constructor): RouteDefinition[];
25
+ getParameters(controller: Constructor): Map<string | symbol, ParameterMetadata[]>;
26
+ getContextIndices(controller: Constructor): Map<string | symbol, number>;
27
+ getModuleOptions(module: Constructor): ModuleOptions | undefined;
28
+ getControllerComponents<T extends MetadataComponentType>(type: T, controller: Constructor): MetadataComponentTypeMap[T][];
29
+ getHandlerComponents<T extends MetadataComponentType>(type: T, controller: Constructor, handlerName: string | symbol): MetadataComponentTypeMap[T][];
30
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { Context, Next } from 'hono';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Interface for HTTP middleware components
5
+ * Middleware can process requests before they reach the route handler
6
+ * and modify both the request and response
7
+ */
8
+ export interface IMiddleware {
9
+ /**
10
+ * Processes an HTTP request/response
11
+ * @param c - The Hono context containing request and response information
12
+ * @param next - Function to call the next middleware in the chain
13
+ * @returns A Promise that resolves to a Response or void
14
+ * @throws {Error} If middleware processing fails
15
+ */
16
+ use(c: Context, next: Next): Promise<Response | void>;
17
+ }
18
+ /**
19
+ * Type for middleware implementations
20
+ * Can be either a class implementing IMiddleware or an instance of IMiddleware
21
+ */
22
+ export type MiddlewareType = Constructor<IMiddleware> | IMiddleware;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { Constructor } from '../types';
2
+ /**
3
+ * Options for configuring a module
4
+ */
5
+ export interface ModuleOptions {
6
+ /**
7
+ * List of controller classes
8
+ */
9
+ controllers?: Constructor[];
10
+ /**
11
+ * List of service classes
12
+ */
13
+ services?: Constructor[];
14
+ /**
15
+ * List of imported modules
16
+ */
17
+ imports?: Constructor[];
18
+ }
@@ -0,0 +1 @@
1
+ export {};