@hono-di/core 0.0.6
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/core.cjs +1554 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +339 -0
- package/dist/core.d.ts +339 -0
- package/dist/core.js +1519 -0
- package/dist/core.js.map +1 -0
- package/dist/decorators.cjs +345 -0
- package/dist/decorators.cjs.map +1 -0
- package/dist/decorators.d.cts +70 -0
- package/dist/decorators.d.ts +70 -0
- package/dist/decorators.js +302 -0
- package/dist/decorators.js.map +1 -0
- package/dist/index.cjs +1850 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +1772 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces-4oTuNIHA.d.cts +139 -0
- package/dist/interfaces-4oTuNIHA.d.ts +139 -0
- package/package.json +39 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { HonoRequest, Context, Next, MiddlewareHandler, Hono } 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;
|
|
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
|
+
}
|
|
138
|
+
|
|
139
|
+
export { type ArgumentsHost as A, type BeforeApplicationShutdown as B, type CanActivate as C, type DynamicModule as D, type ExceptionFilter as E, type FactoryProvider as F, type HttpArgumentsHost as H, type InjectionToken as I, type ModuleOptions as M, type OnModuleInit as O, type PipeTransform as P, RequestMethod as R, Scope as S, type Type as T, type ValueProvider as V, type Interceptor as a, type ExecutionContext as b, type ArgumentMetadata as c, type CallHandler as d, type OnApplicationBootstrap as e, type OnModuleDestroy as f, type OnApplicationShutdown as g, type Provider as h, type ClassProvider as i, type ExistingProvider as j, type ForwardReference as k, type HonoDiMiddleware as l, type MiddlewareConsumer as m, type MiddlewareConfigProxy as n, type RouteInfo as o, type HonoDiModule as p, type IApplication as q };
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hono-di/core",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "NestJS-style Dependency Injection for Hono",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./decorators": {
|
|
16
|
+
"types": "./dist/decorators.d.ts",
|
|
17
|
+
"import": "./dist/decorators.js",
|
|
18
|
+
"require": "./dist/decorators.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"test": "bun test"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"reflect-metadata": "^0.2.2"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"hono": "^4",
|
|
33
|
+
"rxjs": "^7.8.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^5.4.0"
|
|
38
|
+
}
|
|
39
|
+
}
|