@forinda/kickjs 0.2.0 → 1.5.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.
- package/package.json +50 -79
- package/README.md +0 -560
- package/dist/cli.js +0 -1324
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts +0 -613
- package/dist/index.js +0 -883
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
DELETED
|
@@ -1,613 +0,0 @@
|
|
|
1
|
-
import { Newable, Container, inject, injectable } from 'inversify';
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { Express, Request, Response, NextFunction, Application } from 'express';
|
|
4
|
-
import * as stream from 'stream';
|
|
5
|
-
import * as net from 'net';
|
|
6
|
-
import * as http from 'http';
|
|
7
|
-
import { EventEmitter } from 'events';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Represents a controller class that can be instantiated.
|
|
11
|
-
* Used in module creation to register controllers.
|
|
12
|
-
*/
|
|
13
|
-
type KickModuleController = Newable<any>;
|
|
14
|
-
/**
|
|
15
|
-
* Represents a middleware class that can be instantiated.
|
|
16
|
-
* Used in module creation to register middlewares.
|
|
17
|
-
*/
|
|
18
|
-
type KickModuleMiddleware = Newable<any>;
|
|
19
|
-
/**
|
|
20
|
-
* Options for creating a module.
|
|
21
|
-
* Includes arrays of controllers and middlewares to be registered in the module.
|
|
22
|
-
*/
|
|
23
|
-
type KickCreateModuleOptionsType = {
|
|
24
|
-
controllers?: KickModuleController[];
|
|
25
|
-
middlewares?: KickModuleMiddleware[];
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* The result of createModule function.
|
|
29
|
-
* Provides an install method to load the module into a dependency container.
|
|
30
|
-
*/
|
|
31
|
-
type KickCreateModuleResultType = {
|
|
32
|
-
install: (container: Container) => void;
|
|
33
|
-
name: string;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Function type for creating a module.
|
|
37
|
-
* Takes `CreateModuleOptionsType` and returns `CreateModuleResultType`.
|
|
38
|
-
* @param {string} name - The name of the module.
|
|
39
|
-
* @param {KickCreateModuleOptionsType} options
|
|
40
|
-
* @returns {KickCreateModuleResultType}
|
|
41
|
-
*/
|
|
42
|
-
type CreateModuleFuncType = <N extends string = "BaseModule">(name: N, options: KickCreateModuleOptionsType) => KickCreateModuleResultType;
|
|
43
|
-
|
|
44
|
-
type BootstrapContext = {
|
|
45
|
-
modules: any[];
|
|
46
|
-
app: Express;
|
|
47
|
-
middlewares?: any[];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "HEAD" | "PATCH" | "TRACE" | "CONNECT" | "ALL";
|
|
51
|
-
type KickNextFn = NextFunction;
|
|
52
|
-
interface KickRequest extends Request {
|
|
53
|
-
}
|
|
54
|
-
interface KickResponse extends Response {
|
|
55
|
-
}
|
|
56
|
-
type KickRequestHandler = (req: KickRequest, res: KickResponse, next: KickNextFn) => Promise<void> | void;
|
|
57
|
-
|
|
58
|
-
type CommandStep = string;
|
|
59
|
-
interface KickCommandDefinition {
|
|
60
|
-
name: string;
|
|
61
|
-
description?: string;
|
|
62
|
-
steps?: CommandStep | CommandStep[];
|
|
63
|
-
}
|
|
64
|
-
interface KickGeneratorsConfig {
|
|
65
|
-
controllerRoot?: string;
|
|
66
|
-
}
|
|
67
|
-
interface KickAppConfig {
|
|
68
|
-
name?: string;
|
|
69
|
-
port?: number;
|
|
70
|
-
host?: string;
|
|
71
|
-
prefix?: string;
|
|
72
|
-
env?: 'development' | 'production' | string;
|
|
73
|
-
}
|
|
74
|
-
interface KickDevConfig {
|
|
75
|
-
port?: number;
|
|
76
|
-
host?: string;
|
|
77
|
-
entry?: string;
|
|
78
|
-
watch?: boolean;
|
|
79
|
-
env?: Record<string, string>;
|
|
80
|
-
}
|
|
81
|
-
interface KickStartConfig {
|
|
82
|
-
port?: number;
|
|
83
|
-
host?: string;
|
|
84
|
-
entry?: string;
|
|
85
|
-
env?: Record<string, string>;
|
|
86
|
-
}
|
|
87
|
-
interface KickCliConfig {
|
|
88
|
-
commands?: KickCommandDefinition[];
|
|
89
|
-
generators?: KickGeneratorsConfig;
|
|
90
|
-
structure?: KickStructureConfig;
|
|
91
|
-
app?: KickAppConfig;
|
|
92
|
-
dev?: KickDevConfig;
|
|
93
|
-
start?: KickStartConfig;
|
|
94
|
-
}
|
|
95
|
-
interface KickStructureConfig {
|
|
96
|
-
domainRoot?: string;
|
|
97
|
-
domainFolders?: string[];
|
|
98
|
-
defaultDomain?: string;
|
|
99
|
-
}
|
|
100
|
-
type KickConfig = KickCliConfig;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* The application context interface for KickJS applications.
|
|
104
|
-
* Holds request handlers, middlewares, and the Express application instance.
|
|
105
|
-
*/
|
|
106
|
-
interface KickApplicationContext {
|
|
107
|
-
requestHandlers: Record<string, KickRouteMetadata>;
|
|
108
|
-
middlewares: KickAppMiddleware[];
|
|
109
|
-
app: Application;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* A middleware handler function that operates on the application context.
|
|
113
|
-
* @param context - The application context.
|
|
114
|
-
* @returns A promise that resolves when the middleware has completed its operation.
|
|
115
|
-
*/
|
|
116
|
-
interface KickAppMiddleware {
|
|
117
|
-
use: KickRequestHandler;
|
|
118
|
-
}
|
|
119
|
-
type KickAppPlugin = {
|
|
120
|
-
install: (context: KickApplicationContext) => void;
|
|
121
|
-
};
|
|
122
|
-
interface KickApplication {
|
|
123
|
-
context: KickApplicationContext;
|
|
124
|
-
name: string;
|
|
125
|
-
config?: KickAppConfig;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
type CreateRouteType = {
|
|
129
|
-
middlewares?: KickAppMiddleware[];
|
|
130
|
-
};
|
|
131
|
-
type KickRouteMetadata = {
|
|
132
|
-
path: string;
|
|
133
|
-
method: string;
|
|
134
|
-
handlerName: string;
|
|
135
|
-
handler: Function;
|
|
136
|
-
middlewares?: CreateRouteType["middlewares"];
|
|
137
|
-
};
|
|
138
|
-
type KickControllerOptions = {
|
|
139
|
-
middlewares?: KickAppMiddleware[];
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Request context that gets injected into controller methods
|
|
144
|
-
* Contains all the necessary Express objects and metadata for handling HTTP requests
|
|
145
|
-
*/
|
|
146
|
-
interface KickRequestContext {
|
|
147
|
-
/**
|
|
148
|
-
* Express request object
|
|
149
|
-
*/
|
|
150
|
-
req: KickRequest;
|
|
151
|
-
/**
|
|
152
|
-
* Express response object
|
|
153
|
-
*/
|
|
154
|
-
res: KickResponse;
|
|
155
|
-
/**
|
|
156
|
-
* Express next function for middleware chaining
|
|
157
|
-
*/
|
|
158
|
-
next: KickNextFn;
|
|
159
|
-
/**
|
|
160
|
-
* Additional metadata about the request/route
|
|
161
|
-
*/
|
|
162
|
-
meta: {
|
|
163
|
-
/**
|
|
164
|
-
* The route path pattern (e.g., "/todos/:id")
|
|
165
|
-
*/
|
|
166
|
-
routePath: string;
|
|
167
|
-
/**
|
|
168
|
-
* The HTTP method (GET, POST, etc.)
|
|
169
|
-
*/
|
|
170
|
-
method: string;
|
|
171
|
-
/**
|
|
172
|
-
* The controller class name
|
|
173
|
-
*/
|
|
174
|
-
controllerName: string;
|
|
175
|
-
/**
|
|
176
|
-
* The handler method name
|
|
177
|
-
*/
|
|
178
|
-
handlerName: string;
|
|
179
|
-
/**
|
|
180
|
-
* Timestamp when the request started processing
|
|
181
|
-
*/
|
|
182
|
-
startTime: number;
|
|
183
|
-
/**
|
|
184
|
-
* Request ID for tracking/logging
|
|
185
|
-
*/
|
|
186
|
-
requestId: string;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
declare function KickGet<PathName extends string>(path: PathName, options?: CreateRouteType): (target: any, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => void;
|
|
191
|
-
declare function KickPost<PathName extends string>(path: PathName, options?: CreateRouteType): (target: any, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => void;
|
|
192
|
-
declare function KickPut<PathName extends string>(path: PathName, options?: CreateRouteType): (target: any, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => void;
|
|
193
|
-
declare function KickPatch<PathName extends string>(path: PathName, options?: CreateRouteType): (target: any, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => void;
|
|
194
|
-
declare function KickDelete<PathName extends string>(path: PathName, options?: CreateRouteType): (target: any, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => void;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* @author Felix Orinda
|
|
198
|
-
* @decorator `KickController`:
|
|
199
|
-
* Decorator to define a controller with a base path and options.
|
|
200
|
-
* Also marks the class as injectable for DI.
|
|
201
|
-
* @param {string} path
|
|
202
|
-
* @param {KickControllerOptions} options
|
|
203
|
-
* @returns
|
|
204
|
-
*/
|
|
205
|
-
declare function KickController<PathName extends string>(path: PathName, options?: KickControllerOptions): ClassDecorator;
|
|
206
|
-
|
|
207
|
-
declare function AutoBind(target: any): void;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* KickMiddleware decorator options
|
|
211
|
-
*/
|
|
212
|
-
interface KickMiddlewareOptions {
|
|
213
|
-
/**
|
|
214
|
-
* Optional name for the middleware (for logging/debugging)
|
|
215
|
-
*/
|
|
216
|
-
name?: string;
|
|
217
|
-
/**
|
|
218
|
-
* Priority for middleware execution order (lower numbers execute first)
|
|
219
|
-
*/
|
|
220
|
-
priority?: number;
|
|
221
|
-
/**
|
|
222
|
-
* Whether this middleware should be applied globally
|
|
223
|
-
*/
|
|
224
|
-
global?: boolean;
|
|
225
|
-
/**
|
|
226
|
-
* Optional tags for categorizing middleware
|
|
227
|
-
*/
|
|
228
|
-
tags?: string[];
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* @decorator `KickMiddleware`:
|
|
232
|
-
* Decorator to define a middleware class with automatic property binding and DI registration.
|
|
233
|
-
* This decorator automatically applies AutoBind and makes the class injectable.
|
|
234
|
-
*
|
|
235
|
-
* @param {KickMiddlewareOptions} options - Optional middleware configuration
|
|
236
|
-
* @returns {ClassDecorator}
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* ```typescript
|
|
240
|
-
* @KickMiddleware({ name: 'Logger', priority: 1, global: true })
|
|
241
|
-
* export class LoggerMiddleware extends BaseKickMiddleware {
|
|
242
|
-
* use = (req: KickRequest, res: KickResponse, next: KickNextFn) => {
|
|
243
|
-
* console.log(`${req.method} ${req.url}`);
|
|
244
|
-
* next();
|
|
245
|
-
* }
|
|
246
|
-
* }
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
declare function KickMiddleware(options?: KickMiddlewareOptions): ClassDecorator;
|
|
250
|
-
/**
|
|
251
|
-
* Helper function to check if a class is a KickMiddleware
|
|
252
|
-
*/
|
|
253
|
-
declare function isKickMiddleware(target: any): boolean;
|
|
254
|
-
/**
|
|
255
|
-
* Helper function to get middleware metadata from a class
|
|
256
|
-
*/
|
|
257
|
-
declare function getMiddlewareMetadata(target: any): KickMiddlewareOptions & {
|
|
258
|
-
className: string;
|
|
259
|
-
} | undefined;
|
|
260
|
-
|
|
261
|
-
declare const KICK_MODULE_KEYS: {
|
|
262
|
-
KickControllerType: symbol;
|
|
263
|
-
KickMiddlewareType: symbol;
|
|
264
|
-
};
|
|
265
|
-
declare const KICK_CONTROLLER_METADATA_KEYS: {
|
|
266
|
-
path: symbol;
|
|
267
|
-
options: symbol;
|
|
268
|
-
routes: symbol;
|
|
269
|
-
middlewares: symbol;
|
|
270
|
-
middlewareOptions: symbol;
|
|
271
|
-
isMiddleware: symbol;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Map the controller metadata to a route configuration
|
|
276
|
-
* @param {KickModuleController} controller
|
|
277
|
-
* @returns {KickRouteMetadata[]}
|
|
278
|
-
*/
|
|
279
|
-
declare function mapController(controller: KickModuleController): {
|
|
280
|
-
path: string;
|
|
281
|
-
middlewares: KickAppMiddleware[];
|
|
282
|
-
method: string;
|
|
283
|
-
handlerName: string;
|
|
284
|
-
handler: Function;
|
|
285
|
-
}[];
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Normalizes a route path by ensuring it starts with a `'/'` and does not end with a `'/'`.
|
|
289
|
-
* @param {any} path
|
|
290
|
-
* @returns {string}
|
|
291
|
-
*/
|
|
292
|
-
declare function normalizeRoutePath(path: any): string;
|
|
293
|
-
/**
|
|
294
|
-
* Combine base path and route path into a full path
|
|
295
|
-
* @param {string} basePath
|
|
296
|
-
* @param {string} routePath
|
|
297
|
-
* @returns {string}
|
|
298
|
-
*/
|
|
299
|
-
declare function combineRoutePaths(basePath: string, routePath: string): string;
|
|
300
|
-
|
|
301
|
-
declare const KickInject: typeof inject;
|
|
302
|
-
declare const KickInjectable: typeof injectable;
|
|
303
|
-
|
|
304
|
-
declare function bindClassMethods(instance: any): void;
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Route mapper utility for creating contextual handlers
|
|
308
|
-
*/
|
|
309
|
-
declare class RouteMapper {
|
|
310
|
-
/**
|
|
311
|
-
* Creates a contextual handler that injects request context into controller methods
|
|
312
|
-
* @param controller - The controller instance
|
|
313
|
-
* @param route - The route metadata
|
|
314
|
-
* @param prefix - Optional prefix to prepend to route paths
|
|
315
|
-
* @returns Express-compatible handler function
|
|
316
|
-
*/
|
|
317
|
-
static createContextualHandler(controller: any, route: KickRouteMetadata, prefix?: string): (req: KickRequest, res: KickResponse, next: KickNextFn) => any;
|
|
318
|
-
/**
|
|
319
|
-
* Builds the full route path by combining prefix and route path
|
|
320
|
-
* @param prefix - The prefix to prepend
|
|
321
|
-
* @param routePath - The route path
|
|
322
|
-
* @returns Combined route path
|
|
323
|
-
*/
|
|
324
|
-
static buildRoutePath(prefix: string, routePath: string): string;
|
|
325
|
-
/**
|
|
326
|
-
* Maps a controller to its routes with optional prefix
|
|
327
|
-
* @param controller - The controller instance
|
|
328
|
-
* @param routes - The route metadata array
|
|
329
|
-
* @param prefix - Optional prefix to prepend to all routes
|
|
330
|
-
* @returns Array of mapped route information
|
|
331
|
-
*/
|
|
332
|
-
static mapControllerRoutes(controller: any, routes: KickRouteMetadata[], prefix?: string): {
|
|
333
|
-
fullPath: string;
|
|
334
|
-
handler: (req: KickRequest, res: KickResponse, next: KickNextFn) => any;
|
|
335
|
-
controllerName: any;
|
|
336
|
-
path: string;
|
|
337
|
-
method: string;
|
|
338
|
-
handlerName: string;
|
|
339
|
-
middlewares?: CreateRouteType["middlewares"];
|
|
340
|
-
}[];
|
|
341
|
-
/**
|
|
342
|
-
* Logs route registration information
|
|
343
|
-
* @param method - HTTP method
|
|
344
|
-
* @param path - Route path
|
|
345
|
-
* @param handlerName - Handler method name
|
|
346
|
-
* @param controllerName - Controller class name
|
|
347
|
-
* @param prefix - Optional prefix used
|
|
348
|
-
*/
|
|
349
|
-
static logRouteRegistration(method: string, path: string, handlerName: string, controllerName: string, prefix?: string): void;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Load KickJS app configuration for use in applications
|
|
354
|
-
*/
|
|
355
|
-
declare function loadAppConfig(overrides?: Partial<KickAppConfig>): Promise<KickAppConfig>;
|
|
356
|
-
/**
|
|
357
|
-
* Get app configuration from environment variables and config
|
|
358
|
-
*/
|
|
359
|
-
declare function getConfigFromEnv(): Partial<KickAppConfig>;
|
|
360
|
-
|
|
361
|
-
declare class KickApp extends EventEmitter implements KickApplication {
|
|
362
|
-
context: KickApplicationContext;
|
|
363
|
-
name: string;
|
|
364
|
-
prefix: string;
|
|
365
|
-
config?: KickAppConfig;
|
|
366
|
-
private container;
|
|
367
|
-
private _isInitialized;
|
|
368
|
-
private _state;
|
|
369
|
-
constructor(context: KickApplicationContext, name?: string, prefix?: string, config?: KickAppConfig);
|
|
370
|
-
get isInitialized(): boolean;
|
|
371
|
-
get controllers(): any[];
|
|
372
|
-
get state(): Readonly<Record<string, any>>;
|
|
373
|
-
setState(key: string, value: any): void;
|
|
374
|
-
getState(key: string): any;
|
|
375
|
-
onStateChange(key: string, listener: (data: {
|
|
376
|
-
value: any;
|
|
377
|
-
oldValue: any;
|
|
378
|
-
}) => void): void;
|
|
379
|
-
offStateChange(key: string, listener: (data: {
|
|
380
|
-
value: any;
|
|
381
|
-
oldValue: any;
|
|
382
|
-
}) => void): void;
|
|
383
|
-
/**
|
|
384
|
-
* Get a configuration value by key path (supports nested access like 'database.host')
|
|
385
|
-
*/
|
|
386
|
-
getConfig<T = any>(key?: string): T | undefined;
|
|
387
|
-
/**
|
|
388
|
-
* Check if a configuration key exists
|
|
389
|
-
*/
|
|
390
|
-
hasConfig(key: string): boolean;
|
|
391
|
-
/**
|
|
392
|
-
* Get config value with fallback
|
|
393
|
-
*/
|
|
394
|
-
getConfigOrDefault<T>(key: string, defaultValue: T): T;
|
|
395
|
-
loadPlugin(plugins: KickAppPlugin | KickAppPlugin[]): this;
|
|
396
|
-
registerMiddleware(middleware: KickAppMiddleware | KickAppMiddleware[]): this;
|
|
397
|
-
mountMiddlewares(): this;
|
|
398
|
-
loadModules(modules: KickCreateModuleResultType[]): this;
|
|
399
|
-
private extractMiddlewaresFromContainer;
|
|
400
|
-
private mapControllers;
|
|
401
|
-
getContainer(): Container;
|
|
402
|
-
getStats(): {
|
|
403
|
-
name: string;
|
|
404
|
-
isInitialized: boolean;
|
|
405
|
-
controllersCount: number;
|
|
406
|
-
middlewaresCount: number;
|
|
407
|
-
routes: string[];
|
|
408
|
-
routesCount: number;
|
|
409
|
-
state: Readonly<Record<string, any>>;
|
|
410
|
-
};
|
|
411
|
-
addErrorHandler(handler: (error: Error, context?: any) => void): void;
|
|
412
|
-
handleError(error: Error, context?: any): void;
|
|
413
|
-
addRequestInterceptor(interceptor: (req: KickRequest, res: KickResponse, next: KickNextFn) => void): void;
|
|
414
|
-
}
|
|
415
|
-
type CreateKickAppOptions = {
|
|
416
|
-
name?: string;
|
|
417
|
-
prefix?: string;
|
|
418
|
-
config?: KickAppConfig;
|
|
419
|
-
app: KickApplicationContext["app"];
|
|
420
|
-
plugins?: KickAppPlugin[];
|
|
421
|
-
globalMiddlewares?: KickAppMiddleware[];
|
|
422
|
-
modules: KickCreateModuleResultType[];
|
|
423
|
-
};
|
|
424
|
-
declare function createKickApp(options: CreateKickAppOptions): {
|
|
425
|
-
listen: {
|
|
426
|
-
(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
427
|
-
(port?: number, hostname?: string, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
428
|
-
(port?: number, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
429
|
-
(port?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
430
|
-
(path: string, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
431
|
-
(path: string, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
432
|
-
(options: net.ListenOptions, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
433
|
-
(handle: any, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
434
|
-
(handle: any, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
435
|
-
};
|
|
436
|
-
close: (callback?: (err?: Error) => void) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
437
|
-
address: () => net.AddressInfo | string | null;
|
|
438
|
-
getConnections: (cb: (error: Error | null, count: number) => void) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
439
|
-
on: {
|
|
440
|
-
(event: string, listener: (...args: any[]) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
441
|
-
(event: "close", listener: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
442
|
-
(event: "connection", listener: (socket: net.Socket) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
443
|
-
(event: "error", listener: (err: Error) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
444
|
-
(event: "listening", listener: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
445
|
-
(event: "checkContinue", listener: http.RequestListener<typeof http.IncomingMessage, typeof http.ServerResponse>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
446
|
-
(event: "checkExpectation", listener: http.RequestListener<typeof http.IncomingMessage, typeof http.ServerResponse>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
447
|
-
(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
448
|
-
(event: "connect", listener: (req: http.IncomingMessage, socket: stream.Duplex, head: Buffer) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
449
|
-
(event: "dropRequest", listener: (req: http.IncomingMessage, socket: stream.Duplex) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
450
|
-
(event: "request", listener: http.RequestListener<typeof http.IncomingMessage, typeof http.ServerResponse>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
451
|
-
(event: "upgrade", listener: (req: http.IncomingMessage, socket: stream.Duplex, head: Buffer) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
452
|
-
};
|
|
453
|
-
off: <K>(eventName: string | symbol, listener: (...args: any[]) => void) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
454
|
-
emit: {
|
|
455
|
-
(event: string, ...args: any[]): boolean;
|
|
456
|
-
(event: "close"): boolean;
|
|
457
|
-
(event: "connection", socket: net.Socket): boolean;
|
|
458
|
-
(event: "error", err: Error): boolean;
|
|
459
|
-
(event: "listening"): boolean;
|
|
460
|
-
(event: "checkContinue", req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage> & {
|
|
461
|
-
req: http.IncomingMessage;
|
|
462
|
-
}): boolean;
|
|
463
|
-
(event: "checkExpectation", req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage> & {
|
|
464
|
-
req: http.IncomingMessage;
|
|
465
|
-
}): boolean;
|
|
466
|
-
(event: "clientError", err: Error, socket: stream.Duplex): boolean;
|
|
467
|
-
(event: "connect", req: http.IncomingMessage, socket: stream.Duplex, head: Buffer): boolean;
|
|
468
|
-
(event: "dropRequest", req: http.IncomingMessage, socket: stream.Duplex): boolean;
|
|
469
|
-
(event: "request", req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage> & {
|
|
470
|
-
req: http.IncomingMessage;
|
|
471
|
-
}): boolean;
|
|
472
|
-
(event: "upgrade", req: http.IncomingMessage, socket: stream.Duplex, head: Buffer): boolean;
|
|
473
|
-
};
|
|
474
|
-
kickApp: KickApp;
|
|
475
|
-
app: express.Application;
|
|
476
|
-
getStats: () => {
|
|
477
|
-
name: string;
|
|
478
|
-
isInitialized: boolean;
|
|
479
|
-
controllersCount: number;
|
|
480
|
-
middlewaresCount: number;
|
|
481
|
-
routes: string[];
|
|
482
|
-
routesCount: number;
|
|
483
|
-
state: Readonly<Record<string, any>>;
|
|
484
|
-
};
|
|
485
|
-
getState: () => Readonly<Record<string, any>>;
|
|
486
|
-
setState: (key: string, value: any) => void;
|
|
487
|
-
onStateChange: (key: string, listener: any) => void;
|
|
488
|
-
onKickEvent: (event: string, listener: any) => KickApp;
|
|
489
|
-
offKickEvent: (event: string, listener: any) => KickApp;
|
|
490
|
-
emitKickEvent: (event: string, data?: any) => boolean;
|
|
491
|
-
addErrorHandler: (handler: any) => void;
|
|
492
|
-
handleError: (error: Error, context?: any) => void;
|
|
493
|
-
};
|
|
494
|
-
/**
|
|
495
|
-
* Create a KickApp with automatic config loading
|
|
496
|
-
*/
|
|
497
|
-
declare function createKickAppWithConfig(options: Omit<CreateKickAppOptions, 'config'> & {
|
|
498
|
-
configOverrides?: Partial<KickAppConfig>;
|
|
499
|
-
}): Promise<{
|
|
500
|
-
listen: {
|
|
501
|
-
(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
502
|
-
(port?: number, hostname?: string, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
503
|
-
(port?: number, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
504
|
-
(port?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
505
|
-
(path: string, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
506
|
-
(path: string, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
507
|
-
(options: net.ListenOptions, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
508
|
-
(handle: any, backlog?: number, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
509
|
-
(handle: any, listeningListener?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
510
|
-
};
|
|
511
|
-
close: (callback?: (err?: Error) => void) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
512
|
-
address: () => net.AddressInfo | string | null;
|
|
513
|
-
getConnections: (cb: (error: Error | null, count: number) => void) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
514
|
-
on: {
|
|
515
|
-
(event: string, listener: (...args: any[]) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
516
|
-
(event: "close", listener: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
517
|
-
(event: "connection", listener: (socket: net.Socket) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
518
|
-
(event: "error", listener: (err: Error) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
519
|
-
(event: "listening", listener: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
520
|
-
(event: "checkContinue", listener: http.RequestListener<typeof http.IncomingMessage, typeof http.ServerResponse>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
521
|
-
(event: "checkExpectation", listener: http.RequestListener<typeof http.IncomingMessage, typeof http.ServerResponse>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
522
|
-
(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
523
|
-
(event: "connect", listener: (req: http.IncomingMessage, socket: stream.Duplex, head: Buffer) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
524
|
-
(event: "dropRequest", listener: (req: http.IncomingMessage, socket: stream.Duplex) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
525
|
-
(event: "request", listener: http.RequestListener<typeof http.IncomingMessage, typeof http.ServerResponse>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
526
|
-
(event: "upgrade", listener: (req: http.IncomingMessage, socket: stream.Duplex, head: Buffer) => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
527
|
-
};
|
|
528
|
-
off: <K>(eventName: string | symbol, listener: (...args: any[]) => void) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
529
|
-
emit: {
|
|
530
|
-
(event: string, ...args: any[]): boolean;
|
|
531
|
-
(event: "close"): boolean;
|
|
532
|
-
(event: "connection", socket: net.Socket): boolean;
|
|
533
|
-
(event: "error", err: Error): boolean;
|
|
534
|
-
(event: "listening"): boolean;
|
|
535
|
-
(event: "checkContinue", req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage> & {
|
|
536
|
-
req: http.IncomingMessage;
|
|
537
|
-
}): boolean;
|
|
538
|
-
(event: "checkExpectation", req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage> & {
|
|
539
|
-
req: http.IncomingMessage;
|
|
540
|
-
}): boolean;
|
|
541
|
-
(event: "clientError", err: Error, socket: stream.Duplex): boolean;
|
|
542
|
-
(event: "connect", req: http.IncomingMessage, socket: stream.Duplex, head: Buffer): boolean;
|
|
543
|
-
(event: "dropRequest", req: http.IncomingMessage, socket: stream.Duplex): boolean;
|
|
544
|
-
(event: "request", req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage> & {
|
|
545
|
-
req: http.IncomingMessage;
|
|
546
|
-
}): boolean;
|
|
547
|
-
(event: "upgrade", req: http.IncomingMessage, socket: stream.Duplex, head: Buffer): boolean;
|
|
548
|
-
};
|
|
549
|
-
kickApp: KickApp;
|
|
550
|
-
app: express.Application;
|
|
551
|
-
getStats: () => {
|
|
552
|
-
name: string;
|
|
553
|
-
isInitialized: boolean;
|
|
554
|
-
controllersCount: number;
|
|
555
|
-
middlewaresCount: number;
|
|
556
|
-
routes: string[];
|
|
557
|
-
routesCount: number;
|
|
558
|
-
state: Readonly<Record<string, any>>;
|
|
559
|
-
};
|
|
560
|
-
getState: () => Readonly<Record<string, any>>;
|
|
561
|
-
setState: (key: string, value: any) => void;
|
|
562
|
-
onStateChange: (key: string, listener: any) => void;
|
|
563
|
-
onKickEvent: (event: string, listener: any) => KickApp;
|
|
564
|
-
offKickEvent: (event: string, listener: any) => KickApp;
|
|
565
|
-
emitKickEvent: (event: string, data?: any) => boolean;
|
|
566
|
-
addErrorHandler: (handler: any) => void;
|
|
567
|
-
handleError: (error: Error, context?: any) => void;
|
|
568
|
-
}>;
|
|
569
|
-
|
|
570
|
-
declare abstract class BaseKickPlugin implements KickAppPlugin {
|
|
571
|
-
/**
|
|
572
|
-
* Installs the plugin into the application context.
|
|
573
|
-
* The context parameter provides access to the application's components and modules.
|
|
574
|
-
* @param {KickApplicationContext} context
|
|
575
|
-
*/
|
|
576
|
-
abstract install(context: KickApplicationContext): void;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
declare abstract class BaseKickMiddleware implements KickAppMiddleware {
|
|
580
|
-
/**
|
|
581
|
-
* The middleware function to be implemented by subclasses.
|
|
582
|
-
* This function will be called with the request, response, and next function.
|
|
583
|
-
*/
|
|
584
|
-
abstract use: KickRequestHandler;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Creates a module with the given options.
|
|
589
|
-
* This module can then be installed into an Inversify container.
|
|
590
|
-
* Helps load controllers and avoid duplicate bindings.
|
|
591
|
-
* @param {KickCreateModuleOptionsType} options
|
|
592
|
-
* @returns
|
|
593
|
-
*/
|
|
594
|
-
declare const createModule: CreateModuleFuncType;
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Create a KickJS configuration with TypeScript intellisense support
|
|
598
|
-
*/
|
|
599
|
-
declare function createKickConfig(config: KickConfig): KickConfig;
|
|
600
|
-
/**
|
|
601
|
-
* Helper function to create app-specific configuration
|
|
602
|
-
*/
|
|
603
|
-
declare function defineAppConfig(config: KickAppConfig): KickAppConfig;
|
|
604
|
-
/**
|
|
605
|
-
* Helper function to create development configuration
|
|
606
|
-
*/
|
|
607
|
-
declare function defineDevConfig(config: KickDevConfig): KickDevConfig;
|
|
608
|
-
/**
|
|
609
|
-
* Helper function to create production configuration
|
|
610
|
-
*/
|
|
611
|
-
declare function defineStartConfig(config: KickStartConfig): KickStartConfig;
|
|
612
|
-
|
|
613
|
-
export { AutoBind, BaseKickMiddleware, BaseKickPlugin, type BootstrapContext, type CreateModuleFuncType, type CreateRouteType, type HttpMethod, KICK_CONTROLLER_METADATA_KEYS, KICK_MODULE_KEYS, KickApp, type KickAppConfig, type KickAppMiddleware, type KickAppPlugin, type KickApplication, type KickApplicationContext, type KickConfig, KickController, type KickControllerOptions, type KickCreateModuleOptionsType, type KickCreateModuleResultType, KickDelete, type KickDevConfig, KickGet, KickInject, KickInjectable, KickMiddleware, type KickMiddlewareOptions, type KickModuleController, type KickModuleMiddleware, type KickNextFn, KickPatch, KickPost, KickPut, type KickRequest, type KickRequestContext, type KickRequestHandler, type KickResponse, type KickRouteMetadata, type KickStartConfig, RouteMapper, bindClassMethods, combineRoutePaths, createKickApp, createKickAppWithConfig, createKickConfig, createModule, defineAppConfig, defineDevConfig, defineStartConfig, getConfigFromEnv, getMiddlewareMetadata, isKickMiddleware, loadAppConfig, mapController, normalizeRoutePath };
|