@hono-di/core 0.0.7 → 0.0.15
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/decorators-ClTJ_N9c.d.cts +304 -0
- package/dist/decorators-ClTJ_N9c.d.ts +304 -0
- package/dist/decorators.cjs +76 -54
- package/dist/decorators.d.cts +1 -68
- package/dist/decorators.d.ts +1 -68
- package/dist/decorators.js +76 -54
- package/dist/index.cjs +1160 -301
- package/dist/index.d.cts +520 -7
- package/dist/index.d.ts +520 -7
- package/dist/index.js +1159 -300
- package/package.json +2 -1
- package/dist/core.cjs +0 -1552
- package/dist/core.d.cts +0 -339
- package/dist/core.d.ts +0 -339
- package/dist/core.js +0 -1517
- package/dist/interfaces-4oTuNIHA.d.cts +0 -139
- package/dist/interfaces-4oTuNIHA.d.ts +0 -139
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { HonoRequest, Context, Next as Next$1, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
declare enum Scope {
|
|
5
|
+
DEFAULT = 0,
|
|
6
|
+
TRANSIENT = 1,
|
|
7
|
+
REQUEST = 2
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare enum RequestMethod {
|
|
11
|
+
GET = "get",
|
|
12
|
+
POST = "post",
|
|
13
|
+
PUT = "put",
|
|
14
|
+
DELETE = "delete",
|
|
15
|
+
PATCH = "patch",
|
|
16
|
+
ALL = "all",
|
|
17
|
+
OPTIONS = "options",
|
|
18
|
+
HEAD = "head"
|
|
19
|
+
}
|
|
20
|
+
interface ModuleOptions {
|
|
21
|
+
imports?: Array<Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
|
22
|
+
controllers?: Type<any>[];
|
|
23
|
+
providers?: Provider[];
|
|
24
|
+
exports?: Array<DynamicModule | Promise<DynamicModule> | string | symbol | Provider | ForwardReference | Function>;
|
|
25
|
+
}
|
|
26
|
+
interface Type<T = any> extends Function {
|
|
27
|
+
new (...args: any[]): T;
|
|
28
|
+
}
|
|
29
|
+
interface ArgumentsHost {
|
|
30
|
+
getArgs<T extends Array<any> = any[]>(): T;
|
|
31
|
+
getType<TContext extends string = 'http'>(): TContext;
|
|
32
|
+
switchToHttp(): HttpArgumentsHost;
|
|
33
|
+
}
|
|
34
|
+
interface HttpArgumentsHost {
|
|
35
|
+
getRequest<T extends string = any>(): HonoRequest<T, any>;
|
|
36
|
+
getResponse<T = any>(): Context;
|
|
37
|
+
getNext<T = any>(): Next$1;
|
|
38
|
+
getContext(): Context;
|
|
39
|
+
}
|
|
40
|
+
interface ExecutionContext extends ArgumentsHost {
|
|
41
|
+
getClass<T = any>(): Type<T>;
|
|
42
|
+
getHandler(): Function;
|
|
43
|
+
}
|
|
44
|
+
interface ExceptionFilter<T = any> {
|
|
45
|
+
catch(exception: T, host: ArgumentsHost): void;
|
|
46
|
+
}
|
|
47
|
+
interface ArgumentMetadata {
|
|
48
|
+
type: 'body' | 'query' | 'param' | 'custom';
|
|
49
|
+
metatype?: Type<any>;
|
|
50
|
+
data?: string;
|
|
51
|
+
}
|
|
52
|
+
interface PipeTransform<T = any, R = any> {
|
|
53
|
+
transform(value: T, metadata: ArgumentMetadata): R;
|
|
54
|
+
}
|
|
55
|
+
interface CanActivate {
|
|
56
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean>;
|
|
57
|
+
}
|
|
58
|
+
interface CallHandler<T = any> {
|
|
59
|
+
handle(): Observable<T>;
|
|
60
|
+
}
|
|
61
|
+
interface Interceptor<T = any, R = any> {
|
|
62
|
+
intercept(context: ExecutionContext, next: CallHandler<T>): Observable<R> | Promise<Observable<R>>;
|
|
63
|
+
}
|
|
64
|
+
interface OnModuleInit {
|
|
65
|
+
onModuleInit(): any;
|
|
66
|
+
}
|
|
67
|
+
interface OnApplicationBootstrap {
|
|
68
|
+
onApplicationBootstrap(): any;
|
|
69
|
+
}
|
|
70
|
+
interface OnModuleDestroy {
|
|
71
|
+
onModuleDestroy(): any;
|
|
72
|
+
}
|
|
73
|
+
interface BeforeApplicationShutdown {
|
|
74
|
+
beforeApplicationShutdown(signal?: string): any;
|
|
75
|
+
}
|
|
76
|
+
interface OnApplicationShutdown {
|
|
77
|
+
onApplicationShutdown(signal?: string): any;
|
|
78
|
+
}
|
|
79
|
+
type InjectionToken<T = any> = string | symbol | Type<T> | Function | ForwardReference;
|
|
80
|
+
type Provider<T = any> = Type<any> | ClassProvider<T> | ValueProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
81
|
+
interface ClassProvider<T = any> {
|
|
82
|
+
provide: InjectionToken;
|
|
83
|
+
useClass: Type<T>;
|
|
84
|
+
scope?: Scope;
|
|
85
|
+
}
|
|
86
|
+
interface ValueProvider<T = any> {
|
|
87
|
+
provide: InjectionToken;
|
|
88
|
+
useValue: T;
|
|
89
|
+
}
|
|
90
|
+
interface FactoryProvider<T = any> {
|
|
91
|
+
provide: InjectionToken;
|
|
92
|
+
useFactory: (...args: any[]) => T | Promise<T>;
|
|
93
|
+
inject?: InjectionToken[];
|
|
94
|
+
scope?: Scope;
|
|
95
|
+
}
|
|
96
|
+
interface ExistingProvider<T = any> {
|
|
97
|
+
provide: InjectionToken;
|
|
98
|
+
useExisting: InjectionToken;
|
|
99
|
+
}
|
|
100
|
+
interface DynamicModule extends ModuleOptions {
|
|
101
|
+
module: Type<any>;
|
|
102
|
+
global?: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface ForwardReference {
|
|
105
|
+
forwardRef: () => Type<any>;
|
|
106
|
+
}
|
|
107
|
+
interface HonoDiMiddleware {
|
|
108
|
+
use: MiddlewareHandler;
|
|
109
|
+
}
|
|
110
|
+
interface MiddlewareConsumer {
|
|
111
|
+
apply(...middleware: (Type<any> | MiddlewareHandler)[]): MiddlewareConfigProxy;
|
|
112
|
+
}
|
|
113
|
+
interface MiddlewareConfigProxy {
|
|
114
|
+
exclude(...routes: (string | RouteInfo)[]): MiddlewareConfigProxy;
|
|
115
|
+
forRoutes(...routes: (string | Type<any> | RouteInfo)[]): MiddlewareConsumer;
|
|
116
|
+
}
|
|
117
|
+
interface RouteInfo {
|
|
118
|
+
path: string;
|
|
119
|
+
method: RequestMethod;
|
|
120
|
+
}
|
|
121
|
+
interface HonoDiModule {
|
|
122
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
123
|
+
}
|
|
124
|
+
interface IApplication {
|
|
125
|
+
useGlobalFilters(...filters: ExceptionFilter[]): this;
|
|
126
|
+
useGlobalPipes(...pipes: PipeTransform[]): this;
|
|
127
|
+
useGlobalInterceptors(...interceptors: Interceptor[]): this;
|
|
128
|
+
useGlobalGuards(...guards: CanActivate[]): this;
|
|
129
|
+
setGlobalPrefix(prefix: string): this;
|
|
130
|
+
init(): Promise<this>;
|
|
131
|
+
listen(port: number | string, callback?: () => void): Promise<any>;
|
|
132
|
+
getHttpAdapter(): Hono;
|
|
133
|
+
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | string | symbol, options?: {
|
|
134
|
+
strict?: boolean;
|
|
135
|
+
}): TResult;
|
|
136
|
+
close(): Promise<void>;
|
|
137
|
+
getContainer(): any;
|
|
138
|
+
}
|
|
139
|
+
interface RouteMetadataCache {
|
|
140
|
+
guards: CanActivate[];
|
|
141
|
+
interceptors: Interceptor[];
|
|
142
|
+
pipes: PipeTransform[];
|
|
143
|
+
}
|
|
144
|
+
interface CleanupHandler {
|
|
145
|
+
cleanup(): Promise<void> | void;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface InjectableOptions {
|
|
149
|
+
scope?: Scope;
|
|
150
|
+
}
|
|
151
|
+
interface RouteDefinition {
|
|
152
|
+
path: string;
|
|
153
|
+
requestMethod: RequestMethod;
|
|
154
|
+
methodName: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Marks a module as global, making its exports available across the entire application
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Global modules are singletons - they are instantiated once and shared across all modules.
|
|
161
|
+
* Use sparingly, typically for utility modules like logging, configuration, etc.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* @Global()
|
|
166
|
+
* @Module({
|
|
167
|
+
* providers: [LoggerService],
|
|
168
|
+
* exports: [LoggerService]
|
|
169
|
+
* })
|
|
170
|
+
* class LoggerModule {}
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
declare function Global(): ClassDecorator;
|
|
176
|
+
/**
|
|
177
|
+
* Defines a module in the DI container
|
|
178
|
+
*
|
|
179
|
+
* @param options - Module configuration
|
|
180
|
+
* @param options.imports - Other modules whose exports should be available in this module
|
|
181
|
+
* @param options.providers - Services/providers that belong to this module
|
|
182
|
+
* @param options.controllers - Controllers that belong to this module
|
|
183
|
+
* @param options.exports - Subset of providers to make available to other modules
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* @Module({
|
|
188
|
+
* imports: [DatabaseModule],
|
|
189
|
+
* controllers: [UserController],
|
|
190
|
+
* providers: [UserService, UserRepository],
|
|
191
|
+
* exports: [UserService]
|
|
192
|
+
* })
|
|
193
|
+
* class UserModule {}
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
declare function Module(options: ModuleOptions): ClassDecorator;
|
|
199
|
+
/**
|
|
200
|
+
* Marks a class as available for dependency injection
|
|
201
|
+
*
|
|
202
|
+
* @param options - Injectable configuration
|
|
203
|
+
* @param options.scope - Lifecycle scope (DEFAULT, REQUEST, or TRANSIENT)
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* - DEFAULT (singleton): One instance shared across the application
|
|
207
|
+
* - REQUEST: New instance per request
|
|
208
|
+
* - TRANSIENT: New instance every time it's injected
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* Singleton service (default):
|
|
212
|
+
* ```typescript
|
|
213
|
+
* @Injectable()
|
|
214
|
+
* class UserService {
|
|
215
|
+
* constructor(private db: DatabaseService) {}
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* Request-scoped service:
|
|
221
|
+
* ```typescript
|
|
222
|
+
* @Injectable({ scope: Scope.REQUEST })
|
|
223
|
+
* class RequestContextService {
|
|
224
|
+
* private requestId: string;
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
231
|
+
/**
|
|
232
|
+
* Marks a class as a controller and defines its route prefix
|
|
233
|
+
*
|
|
234
|
+
* @param prefix - Base URL path for all routes in this controller
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* @Controller('/users')
|
|
239
|
+
* class UserController {
|
|
240
|
+
* @Get('/:id')
|
|
241
|
+
* findOne(@Param('id') id: string) {
|
|
242
|
+
* return { id };
|
|
243
|
+
* }
|
|
244
|
+
* }
|
|
245
|
+
* // Creates route: GET /users/:id
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
declare function Controller(prefix?: string): ClassDecorator;
|
|
251
|
+
declare const Get: (path?: string) => MethodDecorator;
|
|
252
|
+
declare const Post: (path?: string) => MethodDecorator;
|
|
253
|
+
declare const Put: (path?: string) => MethodDecorator;
|
|
254
|
+
declare const Delete: (path?: string) => MethodDecorator;
|
|
255
|
+
declare const Patch: (path?: string) => MethodDecorator;
|
|
256
|
+
declare const Options: (path?: string) => MethodDecorator;
|
|
257
|
+
declare const Head: (path?: string) => MethodDecorator;
|
|
258
|
+
declare const All: (path?: string) => MethodDecorator;
|
|
259
|
+
declare function Catch(...exceptions: Type<any>[]): ClassDecorator;
|
|
260
|
+
declare function UseFilters(...filters: (Type<ExceptionFilter> | ExceptionFilter)[]): MethodDecorator & ClassDecorator;
|
|
261
|
+
declare function Inject(token: InjectionToken): PropertyDecorator & ParameterDecorator;
|
|
262
|
+
declare function Optional(): PropertyDecorator & ParameterDecorator;
|
|
263
|
+
declare function UseGuards(...guards: (Type<CanActivate> | CanActivate)[]): MethodDecorator & ClassDecorator;
|
|
264
|
+
declare function UseInterceptors(...interceptors: (Type<Interceptor> | Interceptor)[]): MethodDecorator & ClassDecorator;
|
|
265
|
+
declare function UsePipes(...pipes: (Type<PipeTransform> | PipeTransform)[]): MethodDecorator & ClassDecorator;
|
|
266
|
+
declare enum RouteParamtypes {
|
|
267
|
+
REQUEST = 0,
|
|
268
|
+
RESPONSE = 1,
|
|
269
|
+
NEXT = 2,
|
|
270
|
+
BODY = 3,
|
|
271
|
+
QUERY = 4,
|
|
272
|
+
PARAM = 5,
|
|
273
|
+
HEADERS = 6,
|
|
274
|
+
SESSION = 7,
|
|
275
|
+
FILE = 8,
|
|
276
|
+
FILES = 9,
|
|
277
|
+
HOST = 10,
|
|
278
|
+
IP = 11,
|
|
279
|
+
CONTEXT = 12,
|
|
280
|
+
CUSTOM = 13
|
|
281
|
+
}
|
|
282
|
+
declare function assignMetadata(args: any, paramtype: RouteParamtypes, index: number, data?: any, ...pipes: any[]): any;
|
|
283
|
+
declare const Request: (data?: any) => ParameterDecorator;
|
|
284
|
+
declare const Response: (data?: any) => ParameterDecorator;
|
|
285
|
+
declare const Next: (data?: any) => ParameterDecorator;
|
|
286
|
+
declare const Session: (data?: any) => ParameterDecorator;
|
|
287
|
+
declare const FileParam: (data?: any) => ParameterDecorator;
|
|
288
|
+
declare const Files: (data?: any) => ParameterDecorator;
|
|
289
|
+
declare const Ip: (data?: any) => ParameterDecorator;
|
|
290
|
+
declare const HostParam: (data?: any) => ParameterDecorator;
|
|
291
|
+
declare const Ctx: (data?: any) => ParameterDecorator;
|
|
292
|
+
declare function Body(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
293
|
+
declare function Query(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
294
|
+
declare function Param(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
295
|
+
declare function Headers(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
296
|
+
declare function SetMetadata<K = any, V = any>(metadataKey: K, metadataValue: V): CustomDecorator<K>;
|
|
297
|
+
type CustomDecorator<TKey = string> = MethodDecorator & ClassDecorator;
|
|
298
|
+
declare function HttpCode(statusCode: number): MethodDecorator;
|
|
299
|
+
declare function Header(name: string, value: string): MethodDecorator;
|
|
300
|
+
declare function Redirect(url: string, statusCode?: number): MethodDecorator;
|
|
301
|
+
declare function applyDecorators(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
302
|
+
declare function createParamDecorator<FactoryData = any, Output = any>(factory: (data: FactoryData, ctx: ExecutionContext) => Output): (data?: FactoryData) => ParameterDecorator;
|
|
303
|
+
|
|
304
|
+
export { Headers as $, type ArgumentMetadata as A, Request as B, type CanActivate as C, Delete as D, type ExceptionFilter as E, type ForwardReference as F, Global as G, type HttpArgumentsHost as H, type IApplication as I, Response as J, Session as K, FileParam as L, type MiddlewareConsumer as M, Next as N, Options as O, type PipeTransform as P, Files as Q, type RouteInfo as R, Scope as S, type Type as T, UseFilters as U, Ip as V, HostParam as W, Ctx as X, Body as Y, Query as Z, Param as _, type InjectionToken as a, SetMetadata as a0, type CustomDecorator as a1, HttpCode as a2, Header as a3, Redirect as a4, applyDecorators as a5, createParamDecorator as a6, type CallHandler as a7, type OnModuleInit as a8, type OnApplicationBootstrap as a9, type OnModuleDestroy as aa, type BeforeApplicationShutdown as ab, type OnApplicationShutdown as ac, type Provider as ad, type ClassProvider as ae, type ValueProvider as af, type FactoryProvider as ag, type ExistingProvider as ah, type DynamicModule as ai, type HonoDiMiddleware as aj, type HonoDiModule as ak, type RouteMetadataCache as al, type CleanupHandler as am, type Interceptor as b, type ExecutionContext as c, type MiddlewareConfigProxy as d, type ArgumentsHost as e, RequestMethod as f, type ModuleOptions as g, type InjectableOptions as h, type RouteDefinition as i, Module as j, Injectable as k, Controller as l, Get as m, Post as n, Put as o, Patch as p, Head as q, All as r, Catch as s, Inject as t, Optional as u, UseGuards as v, UseInterceptors as w, UsePipes as x, RouteParamtypes as y, assignMetadata as z };
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { HonoRequest, Context, Next as Next$1, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
declare enum Scope {
|
|
5
|
+
DEFAULT = 0,
|
|
6
|
+
TRANSIENT = 1,
|
|
7
|
+
REQUEST = 2
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare enum RequestMethod {
|
|
11
|
+
GET = "get",
|
|
12
|
+
POST = "post",
|
|
13
|
+
PUT = "put",
|
|
14
|
+
DELETE = "delete",
|
|
15
|
+
PATCH = "patch",
|
|
16
|
+
ALL = "all",
|
|
17
|
+
OPTIONS = "options",
|
|
18
|
+
HEAD = "head"
|
|
19
|
+
}
|
|
20
|
+
interface ModuleOptions {
|
|
21
|
+
imports?: Array<Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
|
22
|
+
controllers?: Type<any>[];
|
|
23
|
+
providers?: Provider[];
|
|
24
|
+
exports?: Array<DynamicModule | Promise<DynamicModule> | string | symbol | Provider | ForwardReference | Function>;
|
|
25
|
+
}
|
|
26
|
+
interface Type<T = any> extends Function {
|
|
27
|
+
new (...args: any[]): T;
|
|
28
|
+
}
|
|
29
|
+
interface ArgumentsHost {
|
|
30
|
+
getArgs<T extends Array<any> = any[]>(): T;
|
|
31
|
+
getType<TContext extends string = 'http'>(): TContext;
|
|
32
|
+
switchToHttp(): HttpArgumentsHost;
|
|
33
|
+
}
|
|
34
|
+
interface HttpArgumentsHost {
|
|
35
|
+
getRequest<T extends string = any>(): HonoRequest<T, any>;
|
|
36
|
+
getResponse<T = any>(): Context;
|
|
37
|
+
getNext<T = any>(): Next$1;
|
|
38
|
+
getContext(): Context;
|
|
39
|
+
}
|
|
40
|
+
interface ExecutionContext extends ArgumentsHost {
|
|
41
|
+
getClass<T = any>(): Type<T>;
|
|
42
|
+
getHandler(): Function;
|
|
43
|
+
}
|
|
44
|
+
interface ExceptionFilter<T = any> {
|
|
45
|
+
catch(exception: T, host: ArgumentsHost): void;
|
|
46
|
+
}
|
|
47
|
+
interface ArgumentMetadata {
|
|
48
|
+
type: 'body' | 'query' | 'param' | 'custom';
|
|
49
|
+
metatype?: Type<any>;
|
|
50
|
+
data?: string;
|
|
51
|
+
}
|
|
52
|
+
interface PipeTransform<T = any, R = any> {
|
|
53
|
+
transform(value: T, metadata: ArgumentMetadata): R;
|
|
54
|
+
}
|
|
55
|
+
interface CanActivate {
|
|
56
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean>;
|
|
57
|
+
}
|
|
58
|
+
interface CallHandler<T = any> {
|
|
59
|
+
handle(): Observable<T>;
|
|
60
|
+
}
|
|
61
|
+
interface Interceptor<T = any, R = any> {
|
|
62
|
+
intercept(context: ExecutionContext, next: CallHandler<T>): Observable<R> | Promise<Observable<R>>;
|
|
63
|
+
}
|
|
64
|
+
interface OnModuleInit {
|
|
65
|
+
onModuleInit(): any;
|
|
66
|
+
}
|
|
67
|
+
interface OnApplicationBootstrap {
|
|
68
|
+
onApplicationBootstrap(): any;
|
|
69
|
+
}
|
|
70
|
+
interface OnModuleDestroy {
|
|
71
|
+
onModuleDestroy(): any;
|
|
72
|
+
}
|
|
73
|
+
interface BeforeApplicationShutdown {
|
|
74
|
+
beforeApplicationShutdown(signal?: string): any;
|
|
75
|
+
}
|
|
76
|
+
interface OnApplicationShutdown {
|
|
77
|
+
onApplicationShutdown(signal?: string): any;
|
|
78
|
+
}
|
|
79
|
+
type InjectionToken<T = any> = string | symbol | Type<T> | Function | ForwardReference;
|
|
80
|
+
type Provider<T = any> = Type<any> | ClassProvider<T> | ValueProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
81
|
+
interface ClassProvider<T = any> {
|
|
82
|
+
provide: InjectionToken;
|
|
83
|
+
useClass: Type<T>;
|
|
84
|
+
scope?: Scope;
|
|
85
|
+
}
|
|
86
|
+
interface ValueProvider<T = any> {
|
|
87
|
+
provide: InjectionToken;
|
|
88
|
+
useValue: T;
|
|
89
|
+
}
|
|
90
|
+
interface FactoryProvider<T = any> {
|
|
91
|
+
provide: InjectionToken;
|
|
92
|
+
useFactory: (...args: any[]) => T | Promise<T>;
|
|
93
|
+
inject?: InjectionToken[];
|
|
94
|
+
scope?: Scope;
|
|
95
|
+
}
|
|
96
|
+
interface ExistingProvider<T = any> {
|
|
97
|
+
provide: InjectionToken;
|
|
98
|
+
useExisting: InjectionToken;
|
|
99
|
+
}
|
|
100
|
+
interface DynamicModule extends ModuleOptions {
|
|
101
|
+
module: Type<any>;
|
|
102
|
+
global?: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface ForwardReference {
|
|
105
|
+
forwardRef: () => Type<any>;
|
|
106
|
+
}
|
|
107
|
+
interface HonoDiMiddleware {
|
|
108
|
+
use: MiddlewareHandler;
|
|
109
|
+
}
|
|
110
|
+
interface MiddlewareConsumer {
|
|
111
|
+
apply(...middleware: (Type<any> | MiddlewareHandler)[]): MiddlewareConfigProxy;
|
|
112
|
+
}
|
|
113
|
+
interface MiddlewareConfigProxy {
|
|
114
|
+
exclude(...routes: (string | RouteInfo)[]): MiddlewareConfigProxy;
|
|
115
|
+
forRoutes(...routes: (string | Type<any> | RouteInfo)[]): MiddlewareConsumer;
|
|
116
|
+
}
|
|
117
|
+
interface RouteInfo {
|
|
118
|
+
path: string;
|
|
119
|
+
method: RequestMethod;
|
|
120
|
+
}
|
|
121
|
+
interface HonoDiModule {
|
|
122
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
123
|
+
}
|
|
124
|
+
interface IApplication {
|
|
125
|
+
useGlobalFilters(...filters: ExceptionFilter[]): this;
|
|
126
|
+
useGlobalPipes(...pipes: PipeTransform[]): this;
|
|
127
|
+
useGlobalInterceptors(...interceptors: Interceptor[]): this;
|
|
128
|
+
useGlobalGuards(...guards: CanActivate[]): this;
|
|
129
|
+
setGlobalPrefix(prefix: string): this;
|
|
130
|
+
init(): Promise<this>;
|
|
131
|
+
listen(port: number | string, callback?: () => void): Promise<any>;
|
|
132
|
+
getHttpAdapter(): Hono;
|
|
133
|
+
get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | string | symbol, options?: {
|
|
134
|
+
strict?: boolean;
|
|
135
|
+
}): TResult;
|
|
136
|
+
close(): Promise<void>;
|
|
137
|
+
getContainer(): any;
|
|
138
|
+
}
|
|
139
|
+
interface RouteMetadataCache {
|
|
140
|
+
guards: CanActivate[];
|
|
141
|
+
interceptors: Interceptor[];
|
|
142
|
+
pipes: PipeTransform[];
|
|
143
|
+
}
|
|
144
|
+
interface CleanupHandler {
|
|
145
|
+
cleanup(): Promise<void> | void;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface InjectableOptions {
|
|
149
|
+
scope?: Scope;
|
|
150
|
+
}
|
|
151
|
+
interface RouteDefinition {
|
|
152
|
+
path: string;
|
|
153
|
+
requestMethod: RequestMethod;
|
|
154
|
+
methodName: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Marks a module as global, making its exports available across the entire application
|
|
158
|
+
*
|
|
159
|
+
* @remarks
|
|
160
|
+
* Global modules are singletons - they are instantiated once and shared across all modules.
|
|
161
|
+
* Use sparingly, typically for utility modules like logging, configuration, etc.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* @Global()
|
|
166
|
+
* @Module({
|
|
167
|
+
* providers: [LoggerService],
|
|
168
|
+
* exports: [LoggerService]
|
|
169
|
+
* })
|
|
170
|
+
* class LoggerModule {}
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
declare function Global(): ClassDecorator;
|
|
176
|
+
/**
|
|
177
|
+
* Defines a module in the DI container
|
|
178
|
+
*
|
|
179
|
+
* @param options - Module configuration
|
|
180
|
+
* @param options.imports - Other modules whose exports should be available in this module
|
|
181
|
+
* @param options.providers - Services/providers that belong to this module
|
|
182
|
+
* @param options.controllers - Controllers that belong to this module
|
|
183
|
+
* @param options.exports - Subset of providers to make available to other modules
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* @Module({
|
|
188
|
+
* imports: [DatabaseModule],
|
|
189
|
+
* controllers: [UserController],
|
|
190
|
+
* providers: [UserService, UserRepository],
|
|
191
|
+
* exports: [UserService]
|
|
192
|
+
* })
|
|
193
|
+
* class UserModule {}
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
declare function Module(options: ModuleOptions): ClassDecorator;
|
|
199
|
+
/**
|
|
200
|
+
* Marks a class as available for dependency injection
|
|
201
|
+
*
|
|
202
|
+
* @param options - Injectable configuration
|
|
203
|
+
* @param options.scope - Lifecycle scope (DEFAULT, REQUEST, or TRANSIENT)
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* - DEFAULT (singleton): One instance shared across the application
|
|
207
|
+
* - REQUEST: New instance per request
|
|
208
|
+
* - TRANSIENT: New instance every time it's injected
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* Singleton service (default):
|
|
212
|
+
* ```typescript
|
|
213
|
+
* @Injectable()
|
|
214
|
+
* class UserService {
|
|
215
|
+
* constructor(private db: DatabaseService) {}
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* Request-scoped service:
|
|
221
|
+
* ```typescript
|
|
222
|
+
* @Injectable({ scope: Scope.REQUEST })
|
|
223
|
+
* class RequestContextService {
|
|
224
|
+
* private requestId: string;
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
231
|
+
/**
|
|
232
|
+
* Marks a class as a controller and defines its route prefix
|
|
233
|
+
*
|
|
234
|
+
* @param prefix - Base URL path for all routes in this controller
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* @Controller('/users')
|
|
239
|
+
* class UserController {
|
|
240
|
+
* @Get('/:id')
|
|
241
|
+
* findOne(@Param('id') id: string) {
|
|
242
|
+
* return { id };
|
|
243
|
+
* }
|
|
244
|
+
* }
|
|
245
|
+
* // Creates route: GET /users/:id
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
declare function Controller(prefix?: string): ClassDecorator;
|
|
251
|
+
declare const Get: (path?: string) => MethodDecorator;
|
|
252
|
+
declare const Post: (path?: string) => MethodDecorator;
|
|
253
|
+
declare const Put: (path?: string) => MethodDecorator;
|
|
254
|
+
declare const Delete: (path?: string) => MethodDecorator;
|
|
255
|
+
declare const Patch: (path?: string) => MethodDecorator;
|
|
256
|
+
declare const Options: (path?: string) => MethodDecorator;
|
|
257
|
+
declare const Head: (path?: string) => MethodDecorator;
|
|
258
|
+
declare const All: (path?: string) => MethodDecorator;
|
|
259
|
+
declare function Catch(...exceptions: Type<any>[]): ClassDecorator;
|
|
260
|
+
declare function UseFilters(...filters: (Type<ExceptionFilter> | ExceptionFilter)[]): MethodDecorator & ClassDecorator;
|
|
261
|
+
declare function Inject(token: InjectionToken): PropertyDecorator & ParameterDecorator;
|
|
262
|
+
declare function Optional(): PropertyDecorator & ParameterDecorator;
|
|
263
|
+
declare function UseGuards(...guards: (Type<CanActivate> | CanActivate)[]): MethodDecorator & ClassDecorator;
|
|
264
|
+
declare function UseInterceptors(...interceptors: (Type<Interceptor> | Interceptor)[]): MethodDecorator & ClassDecorator;
|
|
265
|
+
declare function UsePipes(...pipes: (Type<PipeTransform> | PipeTransform)[]): MethodDecorator & ClassDecorator;
|
|
266
|
+
declare enum RouteParamtypes {
|
|
267
|
+
REQUEST = 0,
|
|
268
|
+
RESPONSE = 1,
|
|
269
|
+
NEXT = 2,
|
|
270
|
+
BODY = 3,
|
|
271
|
+
QUERY = 4,
|
|
272
|
+
PARAM = 5,
|
|
273
|
+
HEADERS = 6,
|
|
274
|
+
SESSION = 7,
|
|
275
|
+
FILE = 8,
|
|
276
|
+
FILES = 9,
|
|
277
|
+
HOST = 10,
|
|
278
|
+
IP = 11,
|
|
279
|
+
CONTEXT = 12,
|
|
280
|
+
CUSTOM = 13
|
|
281
|
+
}
|
|
282
|
+
declare function assignMetadata(args: any, paramtype: RouteParamtypes, index: number, data?: any, ...pipes: any[]): any;
|
|
283
|
+
declare const Request: (data?: any) => ParameterDecorator;
|
|
284
|
+
declare const Response: (data?: any) => ParameterDecorator;
|
|
285
|
+
declare const Next: (data?: any) => ParameterDecorator;
|
|
286
|
+
declare const Session: (data?: any) => ParameterDecorator;
|
|
287
|
+
declare const FileParam: (data?: any) => ParameterDecorator;
|
|
288
|
+
declare const Files: (data?: any) => ParameterDecorator;
|
|
289
|
+
declare const Ip: (data?: any) => ParameterDecorator;
|
|
290
|
+
declare const HostParam: (data?: any) => ParameterDecorator;
|
|
291
|
+
declare const Ctx: (data?: any) => ParameterDecorator;
|
|
292
|
+
declare function Body(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
293
|
+
declare function Query(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
294
|
+
declare function Param(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
295
|
+
declare function Headers(property?: string, ...pipes: any[]): ParameterDecorator;
|
|
296
|
+
declare function SetMetadata<K = any, V = any>(metadataKey: K, metadataValue: V): CustomDecorator<K>;
|
|
297
|
+
type CustomDecorator<TKey = string> = MethodDecorator & ClassDecorator;
|
|
298
|
+
declare function HttpCode(statusCode: number): MethodDecorator;
|
|
299
|
+
declare function Header(name: string, value: string): MethodDecorator;
|
|
300
|
+
declare function Redirect(url: string, statusCode?: number): MethodDecorator;
|
|
301
|
+
declare function applyDecorators(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
302
|
+
declare function createParamDecorator<FactoryData = any, Output = any>(factory: (data: FactoryData, ctx: ExecutionContext) => Output): (data?: FactoryData) => ParameterDecorator;
|
|
303
|
+
|
|
304
|
+
export { Headers as $, type ArgumentMetadata as A, Request as B, type CanActivate as C, Delete as D, type ExceptionFilter as E, type ForwardReference as F, Global as G, type HttpArgumentsHost as H, type IApplication as I, Response as J, Session as K, FileParam as L, type MiddlewareConsumer as M, Next as N, Options as O, type PipeTransform as P, Files as Q, type RouteInfo as R, Scope as S, type Type as T, UseFilters as U, Ip as V, HostParam as W, Ctx as X, Body as Y, Query as Z, Param as _, type InjectionToken as a, SetMetadata as a0, type CustomDecorator as a1, HttpCode as a2, Header as a3, Redirect as a4, applyDecorators as a5, createParamDecorator as a6, type CallHandler as a7, type OnModuleInit as a8, type OnApplicationBootstrap as a9, type OnModuleDestroy as aa, type BeforeApplicationShutdown as ab, type OnApplicationShutdown as ac, type Provider as ad, type ClassProvider as ae, type ValueProvider as af, type FactoryProvider as ag, type ExistingProvider as ah, type DynamicModule as ai, type HonoDiMiddleware as aj, type HonoDiModule as ak, type RouteMetadataCache as al, type CleanupHandler as am, type Interceptor as b, type ExecutionContext as c, type MiddlewareConfigProxy as d, type ArgumentsHost as e, RequestMethod as f, type ModuleOptions as g, type InjectableOptions as h, type RouteDefinition as i, Module as j, Injectable as k, Controller as l, Get as m, Post as n, Put as o, Patch as p, Head as q, All as r, Catch as s, Inject as t, Optional as u, UseGuards as v, UseInterceptors as w, UsePipes as x, RouteParamtypes as y, assignMetadata as z };
|