honestjs 0.1.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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/dist/application.d.ts +124 -0
  4. package/dist/constants/index.d.ts +1 -0
  5. package/dist/constants/version.constants.d.ts +5 -0
  6. package/dist/decorators/controller.decorator.d.ts +9 -0
  7. package/dist/decorators/http-method.decorator.d.ts +43 -0
  8. package/dist/decorators/index.d.ts +10 -0
  9. package/dist/decorators/module.decorator.d.ts +8 -0
  10. package/dist/decorators/parameter.decorator.d.ts +41 -0
  11. package/dist/decorators/service.decorator.d.ts +6 -0
  12. package/dist/decorators/use-component.decorator.d.ts +10 -0
  13. package/dist/decorators/use-filters.decorator.d.ts +8 -0
  14. package/dist/decorators/use-guards.decorator.d.ts +9 -0
  15. package/dist/decorators/use-middleware.decorator.d.ts +9 -0
  16. package/dist/decorators/use-pipes.decorator.d.ts +9 -0
  17. package/dist/di/contrainer.d.ts +23 -0
  18. package/dist/di/index.d.ts +1 -0
  19. package/dist/handlers/error.handler.d.ts +31 -0
  20. package/dist/handlers/index.d.ts +2 -0
  21. package/dist/handlers/not-found.handler.d.ts +14 -0
  22. package/dist/helpers/create-error-response.helper.d.ts +25 -0
  23. package/dist/helpers/create-http-method-decorator.helper.d.ts +16 -0
  24. package/dist/helpers/create-param-decorator.helper.d.ts +16 -0
  25. package/dist/helpers/index.d.ts +3 -0
  26. package/dist/index.d.ts +19 -0
  27. package/dist/index.js +1 -0
  28. package/dist/interfaces/controller-options.interface.d.ts +17 -0
  29. package/dist/interfaces/di-container.interface.d.ts +24 -0
  30. package/dist/interfaces/error-response.interface.d.ts +13 -0
  31. package/dist/interfaces/filter.interface.d.ts +20 -0
  32. package/dist/interfaces/guard.interface.d.ts +21 -0
  33. package/dist/interfaces/honest-options.interface.d.ts +78 -0
  34. package/dist/interfaces/http-method-options.interface.d.ts +13 -0
  35. package/dist/interfaces/index.d.ts +14 -0
  36. package/dist/interfaces/middleware.interface.d.ts +22 -0
  37. package/dist/interfaces/module-options.interface.d.ts +18 -0
  38. package/dist/interfaces/parameter-metadata.interface.d.ts +27 -0
  39. package/dist/interfaces/pipe.interface.d.ts +37 -0
  40. package/dist/interfaces/plugin.interface.d.ts +31 -0
  41. package/dist/interfaces/route-definition.interface.d.ts +30 -0
  42. package/dist/interfaces/route-info.interface.d.ts +42 -0
  43. package/dist/managers/component.manager.d.ts +143 -0
  44. package/dist/managers/index.d.ts +2 -0
  45. package/dist/managers/route.manager.d.ts +109 -0
  46. package/dist/registries/index.d.ts +2 -0
  47. package/dist/registries/metadata.registry.d.ts +172 -0
  48. package/dist/registries/route.registry.d.ts +63 -0
  49. package/dist/types/constructor.type.d.ts +12 -0
  50. package/dist/types/index.d.ts +1 -0
  51. package/dist/utils/common.util.d.ts +116 -0
  52. package/dist/utils/index.d.ts +1 -0
  53. package/package.json +51 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Orkhan Karimov <karimovok1@gmail.com> (https://github.com/kerimovok)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # Honest Framework
2
+
3
+ <p align="center">
4
+ <a href="https://github.com/honestjs/" target="blank"><img src="https://avatars.githubusercontent.com/u/197956909" width="120" alt="Honest Logo" /></a>
5
+ </p>
6
+ <p align="center">
7
+ A modern, TypeScript-first web framework built on top of <a href="https://hono.dev/" target="blank">Hono</a>, designed for building scalable and
8
+ maintainable web applications. Honest combines the elegance and architecture of <a href="https://nestjs.com/" target="blank">Nest</a> with the
9
+ ultra-fast performance of Hono, giving you the best of both worlds.
10
+ </p>
11
+
12
+ > ⚠️ **Early Development Warning**
13
+ >
14
+ > Honest is currently in early development (pre-v1.0.0). Please be aware that:
15
+ >
16
+ > - The API is not stable and may change frequently
17
+ > - Breaking changes can occur between minor versions
18
+ > - Some features might be incomplete or missing
19
+ > - Documentation may not always be up to date
20
+ >
21
+ > We recommend not using it in production until v1.0.0 is released.
22
+
23
+ ## Features
24
+
25
+ - 🚀 **High Performance** - Built on top of the ultra-fast Hono framework
26
+ - 📦 **Modular Architecture** - Organize your code into reusable, feature-focused modules
27
+ - 💉 **Dependency Injection** - Built-in DI container for better code organization and testing
28
+ - 🔌 **Plugin System** - Extend functionality through a flexible plugin system
29
+ - 🛣️ **Advanced Routing** - Support for versioning, prefixes, and nested routes
30
+ - 🔒 **Built-in Security** - Guards, middleware, and error handling out of the box
31
+ - 🔄 **Request Pipeline** - Powerful middleware, guards, pipes, and filters
32
+ - 📝 **TypeScript-First** - Built with TypeScript for excellent type safety and IDE support
33
+
34
+ ## Quick Start
35
+
36
+ ### Using Honest CLI _(Coming Soon)_
37
+
38
+ The fastest way to create a new Honest application is to use the Honest CLI:
39
+
40
+ ```bash
41
+ # Install Honest CLI globally
42
+ bun add -g @honestjs/cli
43
+ # or
44
+ pnpm add -g @honestjs/cli
45
+ # or
46
+ yarn global add @honestjs/cli
47
+ # or
48
+ npm install -g @honestjs/cli
49
+
50
+ # Create a new project
51
+ honest new my-project
52
+ cd my-project
53
+
54
+ # Start the development server
55
+ bun dev
56
+ ```
57
+
58
+ This will create a new project with a standard directory structure and all necessary configuration files.
59
+
60
+ ### Manual Setup
61
+
62
+ If you prefer to set up your project manually, follow these steps:
63
+
64
+ 1. Install packages
65
+
66
+ ```bash
67
+ bun add honestjs hono reflect-metadata
68
+ # or
69
+ pnpm add honestjs hono reflect-metadata
70
+ # or
71
+ yarn add honestjs hono reflect-metadata
72
+ # or
73
+ npm install honestjs hono reflect-metadata
74
+ ```
75
+
76
+ 2. Create your first controller:
77
+
78
+ ```typescript
79
+ // app.controller.ts
80
+ import { Controller, Get } from 'honestjs'
81
+
82
+ @Controller()
83
+ class AppController {
84
+ @Get()
85
+ helloWorld() {
86
+ return 'Hello, World!'
87
+ }
88
+ }
89
+
90
+ export default AppController
91
+ ```
92
+
93
+ 3. Create a module:
94
+
95
+ ```typescript
96
+ // app.module.ts
97
+ import { Module } from 'honestjs'
98
+ import { AppController } from './app.controller.ts'
99
+
100
+ @Module({
101
+ controllers: [AppController]
102
+ })
103
+ class AppModule {}
104
+
105
+ export default AppModule
106
+ ```
107
+
108
+ 4. Bootstrap your application:
109
+
110
+ ```typescript
111
+ import 'reflect-metadata'
112
+ import { Application } from 'honestjs'
113
+ import { AppModule } from './app.module'
114
+
115
+ const { app, hono } = await Application.create(AppModule, {
116
+ routing: {
117
+ prefix: 'api',
118
+ version: 1
119
+ }
120
+ })
121
+
122
+ export default hono
123
+ ```
124
+
125
+ ## License
126
+
127
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,124 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonestOptions, RouteInfo } from './interfaces';
3
+ import type { Constructor } from './types';
4
+ /**
5
+ * Main application class for the Honest framework
6
+ * Serves as the entry point for creating and configuring web applications
7
+ *
8
+ * Features:
9
+ * - Module-based architecture for organizing application components
10
+ * - Dependency injection container integration
11
+ * - Plugin system for extending functionality
12
+ * - Route management with versioning support
13
+ * - Global error handling
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const { app } = await Application.create(AppModule, {
18
+ * routing: { prefix: '/api', version: 1 },
19
+ * plugins: [new LoggerPlugin()]
20
+ * });
21
+ * ```
22
+ */
23
+ export declare class Application {
24
+ private readonly hono;
25
+ private readonly container;
26
+ private readonly routeManager;
27
+ private readonly options;
28
+ /**
29
+ * Creates a new Application instance with the specified configuration
30
+ * @param options - Configuration options for the application
31
+ * @param options.routing - Route configuration (prefix, versioning)
32
+ * @param options.plugins - Array of plugins to extend functionality
33
+ * @param options.container - Custom dependency injection container
34
+ * @param options.hono - Hono-specific configuration options
35
+ * @throws {Error} If options are invalid or initialization fails
36
+ */
37
+ constructor(options?: HonestOptions);
38
+ /**
39
+ * Sets up global components from application options
40
+ * Initializes the component manager and registers global middleware,
41
+ * guards, pipes, and filters
42
+ * @private
43
+ */
44
+ private setupComponents;
45
+ /**
46
+ * Sets up global error handlers for the application
47
+ * Configures handlers for 404 Not Found and general error cases
48
+ * @private
49
+ */
50
+ private setupErrorHandlers;
51
+ /**
52
+ * Resolves a plugin from either a constructor or instance
53
+ * @param pluginType - Plugin constructor or instance
54
+ * @returns Resolved plugin instance
55
+ * @private
56
+ * @throws {Error} If plugin instantiation fails
57
+ */
58
+ private resolvePlugin;
59
+ /**
60
+ * Registers a module with the application
61
+ * Processes the module's metadata and registers its controllers
62
+ *
63
+ * @param moduleClass - The module class to register
64
+ * @returns The application instance for method chaining
65
+ * @throws {Error} If module registration fails
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const app = new Application();
70
+ * await app.register(UsersModule)
71
+ * .register(AuthModule);
72
+ * ```
73
+ */
74
+ register(moduleClass: Constructor): Promise<Application>;
75
+ /**
76
+ * Creates and initializes a new application with a root module
77
+ *
78
+ * Process:
79
+ * 1. Creates application instance with provided options
80
+ * 2. Initializes and runs plugin lifecycle hooks
81
+ * 3. Registers the root module
82
+ * 4. Returns both the application and Hono instances
83
+ *
84
+ * @param rootModule - The root module class for the application
85
+ * @param options - Application configuration options
86
+ * @returns Object containing the application and Hono instances
87
+ * @throws {Error} If application creation or module registration fails
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const { app, hono } = await Application.create(AppModule, {
92
+ * routing: { prefix: '/api' }
93
+ * });
94
+ * ```
95
+ */
96
+ static create(rootModule: Constructor, options?: HonestOptions): Promise<{
97
+ app: Application;
98
+ hono: Hono;
99
+ }>;
100
+ /**
101
+ * Gets the underlying Hono instance for direct access
102
+ * Use this method when you need to access Hono-specific features
103
+ *
104
+ * @returns The Hono application instance
105
+ * @example
106
+ * ```ts
107
+ * const hono = app.getApp();
108
+ * hono.use(someHonoMiddleware());
109
+ * ```
110
+ */
111
+ getApp(): Hono;
112
+ /**
113
+ * Gets information about all registered routes in the application
114
+ * Useful for documentation and debugging purposes
115
+ *
116
+ * @returns Array of route information objects (read-only)
117
+ * @example
118
+ * ```ts
119
+ * const routes = app.getRoutes();
120
+ * console.log(routes.map(r => r.path));
121
+ * ```
122
+ */
123
+ getRoutes(): ReadonlyArray<RouteInfo>;
124
+ }
@@ -0,0 +1 @@
1
+ export * from './version.constants';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Symbol to use when marking a route as version-neutral
3
+ * Version-neutral routes are accessible both with and without version prefix
4
+ */
5
+ export declare const VERSION_NEUTRAL: unique symbol;
@@ -0,0 +1,9 @@
1
+ import type { ControllerOptions } from '../interfaces';
2
+ /**
3
+ * Decorator that marks a class as a controller
4
+ * Controllers are responsible for handling incoming requests and returning responses
5
+ * @param route - The base route for all endpoints in this controller
6
+ * @param options - Configuration options for the controller
7
+ * @returns A class decorator function
8
+ */
9
+ export declare function Controller(route?: string, options?: ControllerOptions): ClassDecorator;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * GET method decorator
3
+ * The GET method requests a representation of the specified resource.
4
+ * Requests using GET should only retrieve data and should not contain a request content.
5
+ * @param path - The route path
6
+ */
7
+ export declare const Get: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
8
+ /**
9
+ * POST method decorator
10
+ * The POST method submits an entity to the specified resource,
11
+ * often causing a change in state or side effects on the server.
12
+ * @param path - The route path
13
+ */
14
+ export declare const Post: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
15
+ /**
16
+ * PUT method decorator
17
+ * The PUT method replaces all current representations of the target resource with the request content.
18
+ * @param path - The route path
19
+ */
20
+ export declare const Put: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
21
+ /**
22
+ * DELETE method decorator
23
+ * The DELETE method deletes the specified resource.
24
+ * @param path - The route path
25
+ */
26
+ export declare const Delete: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
27
+ /**
28
+ * PATCH method decorator
29
+ * The PATCH method applies partial modifications to a resource.
30
+ * @param path - The route path
31
+ */
32
+ export declare const Patch: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
33
+ /**
34
+ * OPTIONS method decorator
35
+ * The OPTIONS method describes the communication options for the target resource.
36
+ * @param path - The route path
37
+ */
38
+ export declare const Options: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
39
+ /**
40
+ * ALL method decorator (matches all HTTP methods)
41
+ * @param path - The route path
42
+ */
43
+ export declare const All: (path?: string, options?: import("..").HttpMethodOptions) => MethodDecorator;
@@ -0,0 +1,10 @@
1
+ export * from './controller.decorator';
2
+ export * from './http-method.decorator';
3
+ export * from './module.decorator';
4
+ export * from './parameter.decorator';
5
+ export * from './service.decorator';
6
+ export * from './use-component.decorator';
7
+ export * from './use-filters.decorator';
8
+ export * from './use-guards.decorator';
9
+ export * from './use-middleware.decorator';
10
+ export * from './use-pipes.decorator';
@@ -0,0 +1,8 @@
1
+ import type { ModuleOptions } from '../interfaces';
2
+ /**
3
+ * Decorator that marks a class as a module
4
+ * Modules are used to organize the application structure and dependencies
5
+ * @param options - Configuration options for the module
6
+ * @returns A class decorator function
7
+ */
8
+ export declare function Module(options?: ModuleOptions): ClassDecorator;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Decorator that binds the request body to a parameter
3
+ * @param data - Optional property name to extract from the body
4
+ */
5
+ export declare const Body: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
6
+ /**
7
+ * Decorator that binds a route parameter to a parameter
8
+ * @param data - The parameter name in the route
9
+ */
10
+ export declare const Param: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
11
+ /**
12
+ * Decorator that binds a query parameter to a parameter
13
+ * @param data - The query parameter name
14
+ */
15
+ export declare const Query: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
16
+ /**
17
+ * Decorator that binds a header value to a parameter
18
+ * @param data - The header name
19
+ */
20
+ export declare const Header: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
21
+ /**
22
+ * Decorator that binds the request object to a parameter
23
+ */
24
+ export declare const Req: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
25
+ export declare const Request: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
26
+ /**
27
+ * Decorator that binds the response object to a parameter
28
+ */
29
+ export declare const Res: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
30
+ export declare const Response: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
31
+ /**
32
+ * Decorator that binds the context object to a parameter
33
+ */
34
+ export declare const Ctx: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
35
+ export declare const Context: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
36
+ /**
37
+ * Decorator that binds a context variable to a parameter
38
+ * @param data - The variable name to retrieve from context
39
+ */
40
+ export declare const Var: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
41
+ export declare const Variable: (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Decorator that marks a class as a service
3
+ * Services are singleton classes that can be injected as dependencies
4
+ * @returns A class decorator function
5
+ */
6
+ export declare function Service(): ClassDecorator;
@@ -0,0 +1,10 @@
1
+ import type { ComponentType, ComponentTypeMap } from '../registries';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Generic decorator that applies components of a specific type to a controller class or method
5
+ * @template T - The type of component being applied
6
+ * @param type - The component type identifier
7
+ * @param components - Array of components to apply
8
+ * @returns A decorator function that can be used at class or method level
9
+ */
10
+ export declare function UseComponent<T extends ComponentType>(type: T, ...components: ComponentTypeMap[T][]): (target: Constructor | object, propertyKey?: string | symbol) => void;
@@ -0,0 +1,8 @@
1
+ import type { FilterType } from '../interfaces';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Decorator that applies exception filters to a controller class or method
5
+ * @param filters - Array of exception filters to apply
6
+ * @returns A decorator function that can be used at class or method level
7
+ */
8
+ export declare function UseFilters(...filters: FilterType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
@@ -0,0 +1,9 @@
1
+ import type { GuardType } from '../interfaces';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Decorator that applies guards to a controller class or method
5
+ * Guards determine whether a request should be handled by the route handler
6
+ * @param guards - Array of guards to apply
7
+ * @returns A decorator function that can be used at class or method level
8
+ */
9
+ export declare function UseGuards(...guards: GuardType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
@@ -0,0 +1,9 @@
1
+ import type { MiddlewareType } from '../interfaces';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Decorator that applies middleware to a controller class or method
5
+ * Middleware functions run before the route handler and can modify the request/response
6
+ * @param middleware - Array of middleware functions to apply
7
+ * @returns A decorator function that can be used at class or method level
8
+ */
9
+ export declare function UseMiddleware(...middleware: MiddlewareType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
@@ -0,0 +1,9 @@
1
+ import type { PipeType } from '../interfaces';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Decorator that applies transformation pipes to a controller class or method
5
+ * Pipes transform input data before it reaches the route handler
6
+ * @param pipes - Array of pipes to apply
7
+ * @returns A decorator function that can be used at class or method level
8
+ */
9
+ export declare function UsePipes(...pipes: PipeType[]): (target: Constructor | object, propertyKey?: string | symbol) => void;
@@ -0,0 +1,23 @@
1
+ import type { DiContainer } from '../interfaces';
2
+ import type { Constructor } from '../types';
3
+ /**
4
+ * Dependency Injection container that manages class instances and their dependencies
5
+ */
6
+ export declare class Container implements DiContainer {
7
+ /**
8
+ * Map of class constructors to their instances
9
+ */
10
+ private instances;
11
+ /**
12
+ * Resolves a class instance, creating it if necessary and injecting its dependencies
13
+ * @param target - The class constructor to resolve
14
+ * @returns An instance of the target class
15
+ */
16
+ resolve<T>(target: Constructor<T>): T;
17
+ /**
18
+ * Registers a pre-created instance for a class
19
+ * @param target - The class constructor to register
20
+ * @param instance - The instance to register
21
+ */
22
+ register<T>(target: Constructor<T>, instance: T): void;
23
+ }
@@ -0,0 +1 @@
1
+ export * from './contrainer';
@@ -0,0 +1,31 @@
1
+ import type { Context } from 'hono';
2
+ /**
3
+ * Handler for managing application-wide error responses
4
+ * Provides a consistent way to handle and format error responses across the application
5
+ */
6
+ export declare class ErrorHandler {
7
+ /**
8
+ * Creates a middleware function that handles error responses
9
+ * @returns A middleware function that formats and returns error responses using createErrorResponse
10
+ */
11
+ static handle(): (err: Error, c: Context) => Promise<Response & import("hono").TypedResponse<{
12
+ response: {
13
+ status: number;
14
+ message: string;
15
+ timestamp: string;
16
+ path: string;
17
+ requestId?: string | undefined;
18
+ code?: string | undefined;
19
+ details?: {
20
+ [x: string]: any;
21
+ } | undefined;
22
+ errors?: {
23
+ property: string;
24
+ constraints: {
25
+ [x: string]: string;
26
+ };
27
+ }[] | undefined;
28
+ };
29
+ status: import("hono/utils/http-status").ContentfulStatusCode;
30
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
31
+ }
@@ -0,0 +1,2 @@
1
+ export * from './error.handler';
2
+ export * from './not-found.handler';
@@ -0,0 +1,14 @@
1
+ import type { Context } from 'hono';
2
+ /**
3
+ * Handler for managing 404 Not Found responses
4
+ * Provides a consistent way to handle requests to non-existent routes
5
+ */
6
+ export declare class NotFoundHandler {
7
+ /**
8
+ * Creates a middleware function that handles 404 Not Found responses
9
+ * @returns A middleware function that returns a JSON response with a 404 status
10
+ */
11
+ static handle(): (c: Context) => Promise<Response & import("hono").TypedResponse<{
12
+ message: string;
13
+ }, 404, "json">>;
14
+ }
@@ -0,0 +1,25 @@
1
+ import type { Context } from 'hono';
2
+ import type { ContentfulStatusCode } from 'hono/utils/http-status';
3
+ import type { ErrorResponse } from '../interfaces';
4
+ /**
5
+ * Creates a standardized error response object
6
+ * @param exception - The error or exception object to process
7
+ * @param context - The Hono context object containing request information
8
+ * @param options - Optional configuration for the error response
9
+ * @param options.status - HTTP status code to override the default
10
+ * @param options.title - Custom error message to override the default
11
+ * @param options.detail - Additional error details
12
+ * @param options.code - Custom error code
13
+ * @param options.additionalDetails - Extra information to include in the response
14
+ * @returns Object containing the formatted error response and HTTP status code
15
+ */
16
+ export declare function createErrorResponse(exception: Error, context: Context, options?: {
17
+ status?: number;
18
+ title?: string;
19
+ detail?: string;
20
+ code?: string;
21
+ additionalDetails?: Record<string, any>;
22
+ }): {
23
+ response: ErrorResponse;
24
+ status: ContentfulStatusCode;
25
+ };
@@ -0,0 +1,16 @@
1
+ import type { HttpMethodOptions } from '../interfaces';
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 declare function createHttpMethodDecorator(method: string): (path?: string, options?: HttpMethodOptions) => MethodDecorator;
@@ -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 = any>(type: string, factory?: (data: any, ctx: Context) => T): (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
@@ -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,19 @@
1
+ import 'reflect-metadata';
2
+ export * from './application';
3
+ export * from './constants';
4
+ export * from './decorators';
5
+ export * from './di';
6
+ export * from './handlers';
7
+ export * from './helpers';
8
+ export * from './interfaces';
9
+ export * from './managers';
10
+ export * from './registries';
11
+ export * from './types';
12
+ export * from './utils';
13
+ declare global {
14
+ namespace Reflect {
15
+ function getMetadata(metadataKey: string, target: object): any;
16
+ function defineMetadata(metadataKey: string, metadataValue: any, target: object): void;
17
+ function hasMetadata(metadataKey: string, target: object): boolean;
18
+ }
19
+ }