veloce-ts 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.
- package/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/README.md +442 -0
- package/bin/veloce.ts +2 -0
- package/dist/cjs/src/cli/index.js +425 -0
- package/dist/cjs/src/cli/index.js.map +22 -0
- package/dist/cjs/src/docs/index.js +7 -0
- package/dist/cjs/src/docs/index.js.map +55 -0
- package/dist/cjs/src/errors/index.js +4 -0
- package/dist/cjs/src/errors/index.js.map +12 -0
- package/dist/cjs/src/graphql/index.js +83 -0
- package/dist/cjs/src/graphql/index.js.map +24 -0
- package/dist/cjs/src/index.js +126 -0
- package/dist/cjs/src/index.js.map +108 -0
- package/dist/cjs/src/middleware/index.js +3 -0
- package/dist/cjs/src/middleware/index.js.map +12 -0
- package/dist/cjs/src/plugins/index.js +125 -0
- package/dist/cjs/src/plugins/index.js.map +67 -0
- package/dist/cjs/src/testing/index.js +17 -0
- package/dist/cjs/src/testing/index.js.map +54 -0
- package/dist/cjs/src/types/index.js +3 -0
- package/dist/cjs/src/types/index.js.map +16 -0
- package/dist/cjs/src/validation/index.js +3 -0
- package/dist/cjs/src/validation/index.js.map +19 -0
- package/dist/cjs/src/websocket/index.js +3 -0
- package/dist/cjs/src/websocket/index.js.map +12 -0
- package/dist/esm/chunk-0zxhx5b8.js +7 -0
- package/dist/esm/chunk-0zxhx5b8.js.map +10 -0
- package/dist/esm/chunk-159eqj8q.js +5 -0
- package/dist/esm/chunk-159eqj8q.js.map +12 -0
- package/dist/esm/chunk-1hqjkm44.js +5 -0
- package/dist/esm/chunk-1hqjkm44.js.map +11 -0
- package/dist/esm/chunk-2q6s8v3j.js +6 -0
- package/dist/esm/chunk-2q6s8v3j.js.map +10 -0
- package/dist/esm/chunk-42h6trpf.js +5 -0
- package/dist/esm/chunk-42h6trpf.js.map +9 -0
- package/dist/esm/chunk-82f2j0k2.js +60 -0
- package/dist/esm/chunk-82f2j0k2.js.map +10 -0
- package/dist/esm/chunk-8wrnr45g.js +338 -0
- package/dist/esm/chunk-8wrnr45g.js.map +10 -0
- package/dist/esm/chunk-9p6d0t33.js +5 -0
- package/dist/esm/chunk-9p6d0t33.js.map +10 -0
- package/dist/esm/chunk-awven6dt.js +4 -0
- package/dist/esm/chunk-awven6dt.js.map +16 -0
- package/dist/esm/chunk-gv5n8ddb.js +18 -0
- package/dist/esm/chunk-gv5n8ddb.js.map +10 -0
- package/dist/esm/chunk-pn7z890c.js +72 -0
- package/dist/esm/chunk-pn7z890c.js.map +13 -0
- package/dist/esm/chunk-qfsjy9bg.js +7 -0
- package/dist/esm/chunk-qfsjy9bg.js.map +10 -0
- package/dist/esm/chunk-vkkzgaf7.js +5 -0
- package/dist/esm/chunk-vkkzgaf7.js.map +12 -0
- package/dist/esm/src/cli/index.js +30 -0
- package/dist/esm/src/cli/index.js.map +18 -0
- package/dist/esm/src/docs/index.js +8 -0
- package/dist/esm/src/docs/index.js.map +48 -0
- package/dist/esm/src/errors/index.js +4 -0
- package/dist/esm/src/errors/index.js.map +9 -0
- package/dist/esm/src/graphql/index.js +4 -0
- package/dist/esm/src/graphql/index.js.map +9 -0
- package/dist/esm/src/index.js +4 -0
- package/dist/esm/src/index.js.map +16 -0
- package/dist/esm/src/middleware/index.js +4 -0
- package/dist/esm/src/middleware/index.js.map +9 -0
- package/dist/esm/src/plugins/index.js +42 -0
- package/dist/esm/src/plugins/index.js.map +10 -0
- package/dist/esm/src/testing/index.js +4 -0
- package/dist/esm/src/testing/index.js.map +39 -0
- package/dist/esm/src/types/index.js +4 -0
- package/dist/esm/src/types/index.js.map +9 -0
- package/dist/esm/src/validation/index.js +4 -0
- package/dist/esm/src/validation/index.js.map +9 -0
- package/dist/esm/src/websocket/index.js +4 -0
- package/dist/esm/src/websocket/index.js.map +9 -0
- package/dist/types/adapters/base.d.ts +24 -0
- package/dist/types/adapters/base.d.ts.map +1 -0
- package/dist/types/adapters/express.d.ts +44 -0
- package/dist/types/adapters/express.d.ts.map +1 -0
- package/dist/types/adapters/hono.d.ts +44 -0
- package/dist/types/adapters/hono.d.ts.map +1 -0
- package/dist/types/cli/commands/build.d.ts +3 -0
- package/dist/types/cli/commands/build.d.ts.map +1 -0
- package/dist/types/cli/commands/dev.d.ts +3 -0
- package/dist/types/cli/commands/dev.d.ts.map +1 -0
- package/dist/types/cli/commands/generate.d.ts +3 -0
- package/dist/types/cli/commands/generate.d.ts.map +1 -0
- package/dist/types/cli/commands/new.d.ts +3 -0
- package/dist/types/cli/commands/new.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/core/application.d.ts +268 -0
- package/dist/types/core/application.d.ts.map +1 -0
- package/dist/types/core/compiled-metadata.d.ts +58 -0
- package/dist/types/core/compiled-metadata.d.ts.map +1 -0
- package/dist/types/core/metadata.d.ts +175 -0
- package/dist/types/core/metadata.d.ts.map +1 -0
- package/dist/types/core/plugin.d.ts +63 -0
- package/dist/types/core/plugin.d.ts.map +1 -0
- package/dist/types/core/router-compiler.d.ts +61 -0
- package/dist/types/core/router-compiler.d.ts.map +1 -0
- package/dist/types/decorators/dependencies.d.ts +28 -0
- package/dist/types/decorators/dependencies.d.ts.map +1 -0
- package/dist/types/decorators/docs.d.ts +38 -0
- package/dist/types/decorators/docs.d.ts.map +1 -0
- package/dist/types/decorators/graphql.d.ts +126 -0
- package/dist/types/decorators/graphql.d.ts.map +1 -0
- package/dist/types/decorators/http.d.ts +74 -0
- package/dist/types/decorators/http.d.ts.map +1 -0
- package/dist/types/decorators/middleware.d.ts +30 -0
- package/dist/types/decorators/middleware.d.ts.map +1 -0
- package/dist/types/decorators/params.d.ts +82 -0
- package/dist/types/decorators/params.d.ts.map +1 -0
- package/dist/types/decorators/websocket.d.ts +61 -0
- package/dist/types/decorators/websocket.d.ts.map +1 -0
- package/dist/types/dependencies/container.d.ts +93 -0
- package/dist/types/dependencies/container.d.ts.map +1 -0
- package/dist/types/docs/index.d.ts +3 -0
- package/dist/types/docs/index.d.ts.map +1 -0
- package/dist/types/docs/openapi-generator.d.ts +50 -0
- package/dist/types/docs/openapi-generator.d.ts.map +1 -0
- package/dist/types/docs/zod-to-json-schema.d.ts +46 -0
- package/dist/types/docs/zod-to-json-schema.d.ts.map +1 -0
- package/dist/types/errors/exceptions.d.ts +48 -0
- package/dist/types/errors/exceptions.d.ts.map +1 -0
- package/dist/types/errors/handler.d.ts +61 -0
- package/dist/types/errors/handler.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +7 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/graphql/index.d.ts +4 -0
- package/dist/types/graphql/index.d.ts.map +1 -0
- package/dist/types/graphql/plugin.d.ts +60 -0
- package/dist/types/graphql/plugin.d.ts.map +1 -0
- package/dist/types/graphql/schema-builder.d.ts +46 -0
- package/dist/types/graphql/schema-builder.d.ts.map +1 -0
- package/dist/types/graphql/zod-to-graphql.d.ts +22 -0
- package/dist/types/graphql/zod-to-graphql.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/middleware/compression.d.ts +7 -0
- package/dist/types/middleware/compression.d.ts.map +1 -0
- package/dist/types/middleware/cors.d.ts +7 -0
- package/dist/types/middleware/cors.d.ts.map +1 -0
- package/dist/types/middleware/index.d.ts +4 -0
- package/dist/types/middleware/index.d.ts.map +1 -0
- package/dist/types/middleware/rate-limit.d.ts +7 -0
- package/dist/types/middleware/rate-limit.d.ts.map +1 -0
- package/dist/types/plugins/index.d.ts +4 -0
- package/dist/types/plugins/index.d.ts.map +1 -0
- package/dist/types/plugins/openapi.d.ts +23 -0
- package/dist/types/plugins/openapi.d.ts.map +1 -0
- package/dist/types/responses/response.d.ts +200 -0
- package/dist/types/responses/response.d.ts.map +1 -0
- package/dist/types/testing/helpers.d.ts +98 -0
- package/dist/types/testing/helpers.d.ts.map +1 -0
- package/dist/types/testing/index.d.ts +4 -0
- package/dist/types/testing/index.d.ts.map +1 -0
- package/dist/types/testing/test-client.d.ts +86 -0
- package/dist/types/testing/test-client.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +232 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/validation/exceptions.d.ts +25 -0
- package/dist/types/validation/exceptions.d.ts.map +1 -0
- package/dist/types/validation/index.d.ts +3 -0
- package/dist/types/validation/index.d.ts.map +1 -0
- package/dist/types/validation/validator.d.ts +54 -0
- package/dist/types/validation/validator.d.ts.map +1 -0
- package/dist/types/websocket/connection.d.ts +51 -0
- package/dist/types/websocket/connection.d.ts.map +1 -0
- package/dist/types/websocket/index.d.ts +4 -0
- package/dist/types/websocket/index.d.ts.map +1 -0
- package/dist/types/websocket/manager.d.ts +82 -0
- package/dist/types/websocket/manager.d.ts.map +1 -0
- package/dist/types/websocket/plugin.d.ts +51 -0
- package/dist/types/websocket/plugin.d.ts.map +1 -0
- package/package.json +149 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/core/metadata.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,EAKL,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAYlB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAyC;IACvD,OAAO,CAAC,WAAW,CAA6C;IAChE,OAAO,CAAC,kBAAkB,CAA0C;IACpE,OAAO,CAAC,UAAU,CAA4C;IAC9D,OAAO,CAAC,gBAAgB,CAAkD;IAC1E,OAAO,CAAC,aAAa,CAAgD;IAErE;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAW5C;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,KAAK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,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,wBAAwB,GACjC,IAAI;IA8BP;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,SAAS;IAIhF;;OAEG;IACH,MAAM,CAAC,2BAA2B,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAI1G;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO;IAIjD;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,uBAAuB,GAAG,IAAI;IAIlF;;OAEG;IACH,MAAM,CAAC,kBAAkB,CACvB,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,oBAAoB,GAC7B,IAAI;IAUP;;OAEG;IACH,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,GAAG,GAAG,uBAAuB,GAAG,SAAS;IAInF;;OAEG;IACH,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,GAAG,oBAAoB,EAAE;IAIpE;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAIlG;;OAEG;IACH,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO;IAIvD;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;CAG1E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { VeloceTS } from './application';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin interface that all plugins must implement
|
|
4
|
+
* Plugins can extend the framework with additional functionality
|
|
5
|
+
*/
|
|
6
|
+
export interface Plugin {
|
|
7
|
+
/** Unique name of the plugin */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Optional version string */
|
|
10
|
+
version?: string;
|
|
11
|
+
/** Optional list of plugin names this plugin depends on */
|
|
12
|
+
dependencies?: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Install method called when the plugin is registered
|
|
15
|
+
* @param app - The VeloceTS application instance
|
|
16
|
+
*/
|
|
17
|
+
install(app: VeloceTS): void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* PluginManager handles plugin registration and installation
|
|
21
|
+
* Resolves plugin dependencies using topological sort
|
|
22
|
+
*/
|
|
23
|
+
export declare class PluginManager {
|
|
24
|
+
private plugins;
|
|
25
|
+
private installed;
|
|
26
|
+
/**
|
|
27
|
+
* Register a plugin with the manager
|
|
28
|
+
* @param plugin - The plugin to register
|
|
29
|
+
* @throws Error if plugin with same name is already registered
|
|
30
|
+
*/
|
|
31
|
+
register(plugin: Plugin): void;
|
|
32
|
+
/**
|
|
33
|
+
* Install all registered plugins in dependency order
|
|
34
|
+
* @param app - The VeloceTS application instance
|
|
35
|
+
* @throws Error if plugin dependencies cannot be resolved
|
|
36
|
+
*/
|
|
37
|
+
install(app: VeloceTS): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a plugin is installed
|
|
40
|
+
* @param name - The plugin name
|
|
41
|
+
* @returns true if the plugin is installed
|
|
42
|
+
*/
|
|
43
|
+
isInstalled(name: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get a registered plugin by name
|
|
46
|
+
* @param name - The plugin name
|
|
47
|
+
* @returns The plugin or undefined if not found
|
|
48
|
+
*/
|
|
49
|
+
getPlugin(name: string): Plugin | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Get all registered plugin names
|
|
52
|
+
* @returns Array of plugin names
|
|
53
|
+
*/
|
|
54
|
+
getPluginNames(): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Resolve plugin installation order using topological sort
|
|
57
|
+
* Ensures dependencies are installed before dependents
|
|
58
|
+
* @returns Array of plugin names in installation order
|
|
59
|
+
* @throws Error if circular dependencies are detected or dependencies are missing
|
|
60
|
+
*/
|
|
61
|
+
private resolveInstallOrder;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/core/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,SAAS,CAA0B;IAE3C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAO9B;;;;OAIG;IACG,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3C;;;OAGG;IACH,cAAc,IAAI,MAAM,EAAE;IAI1B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAqD5B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import { MetadataRegistry } from './metadata';
|
|
3
|
+
import { DIContainer } from '../dependencies/container';
|
|
4
|
+
import { ValidationEngine } from '../validation/validator';
|
|
5
|
+
import { ErrorHandler } from '../errors/handler';
|
|
6
|
+
/**
|
|
7
|
+
* RouterCompiler converts metadata from decorators and functional API
|
|
8
|
+
* into actual Hono routes with full validation and dependency injection
|
|
9
|
+
*/
|
|
10
|
+
export declare class RouterCompiler {
|
|
11
|
+
private app;
|
|
12
|
+
private metadata;
|
|
13
|
+
private container;
|
|
14
|
+
private validator;
|
|
15
|
+
private errorHandler;
|
|
16
|
+
private compiledRoutes;
|
|
17
|
+
constructor(app: Hono, metadata: MetadataRegistry, container: DIContainer, validator: ValidationEngine, errorHandler: ErrorHandler);
|
|
18
|
+
/**
|
|
19
|
+
* Compile all registered routes and register them with Hono
|
|
20
|
+
* This is the main entry point that processes all route metadata
|
|
21
|
+
*/
|
|
22
|
+
compile(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Normalize a path to ensure it follows Hono's conventions
|
|
25
|
+
* Converts FastAPI-style path parameters to Hono format
|
|
26
|
+
*/
|
|
27
|
+
private normalizePath;
|
|
28
|
+
/**
|
|
29
|
+
* Create a Hono handler function for a route
|
|
30
|
+
* Integrates parameter extraction, validation, dependency injection, and error handling
|
|
31
|
+
*/
|
|
32
|
+
private createHandler;
|
|
33
|
+
/**
|
|
34
|
+
* Serialize the handler result into a proper HTTP response
|
|
35
|
+
* Delegates to ResponseSerializer for consistent handling
|
|
36
|
+
*/
|
|
37
|
+
private serializeResponse;
|
|
38
|
+
/**
|
|
39
|
+
* Handle errors that occur during request processing
|
|
40
|
+
* Delegates to ErrorHandler for consistent error handling
|
|
41
|
+
*/
|
|
42
|
+
private handleError;
|
|
43
|
+
/**
|
|
44
|
+
* Extract and validate parameters from the request context
|
|
45
|
+
* Handles body, query, params, headers, cookies, and special types
|
|
46
|
+
*/
|
|
47
|
+
private extractParameters;
|
|
48
|
+
/**
|
|
49
|
+
* Merge parameters and dependencies into a single arguments array
|
|
50
|
+
* Ensures each argument is placed at its correct index
|
|
51
|
+
* Note: Returns a sparse array to maintain correct parameter positions
|
|
52
|
+
* Uses pre-computed maxArgumentIndex from compiled metadata for performance
|
|
53
|
+
*/
|
|
54
|
+
private mergeArguments;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve dependencies for a route handler
|
|
57
|
+
* Calls DIContainer.resolve for each dependency with appropriate scope
|
|
58
|
+
*/
|
|
59
|
+
private resolveDependencies;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=router-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-compiler.d.ts","sourceRoot":"","sources":["../../../src/core/router-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAGjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;GAGG;AACH,qBAAa,cAAc;IAKvB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,YAAY;IAPtB,OAAO,CAAC,cAAc,CAAiD;gBAG7D,GAAG,EAAE,IAAI,EACT,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,gBAAgB,EAC3B,YAAY,EAAE,YAAY;IAGpC;;;OAGG;IACH,OAAO,IAAI,IAAI;IAwBf;;;OAGG;IACH,OAAO,CAAC,aAAa;IAiBrB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAqCrB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;;OAGG;YACW,WAAW;IAKzB;;;OAGG;YACW,iBAAiB;IA6G/B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IA8BtB;;;OAGG;YACW,mBAAmB;CA2BlC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Provider, Scope } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* @Depends decorator for dependency injection
|
|
4
|
+
* Marks a parameter to be injected with a dependency from the DI container
|
|
5
|
+
*
|
|
6
|
+
* @param provider - The provider (class or factory) to inject
|
|
7
|
+
* @param scope - The lifecycle scope: 'singleton', 'request', or 'transient'
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* class UserService {
|
|
12
|
+
* constructor() {}
|
|
13
|
+
* getUser(id: string) { return { id, name: 'John' }; }
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* class UserController {
|
|
17
|
+
* @Get('/users/:id')
|
|
18
|
+
* getUser(
|
|
19
|
+
* @Param('id') id: string,
|
|
20
|
+
* @Depends(UserService, 'singleton') userService: UserService
|
|
21
|
+
* ) {
|
|
22
|
+
* return userService.getUser(id);
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function Depends<T>(provider: Provider<T>, scope?: Scope): ParameterDecorator;
|
|
28
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/decorators/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,GAAE,KAAiB,GAAG,kBAAkB,CAc9F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RouteDocumentation, ResponseMetadata } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* ApiDoc decorator - adds documentation metadata to a route
|
|
4
|
+
* @param docs - Documentation object with summary, description, tags, etc.
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* @ApiDoc({
|
|
8
|
+
* summary: 'Get user by ID',
|
|
9
|
+
* description: 'Retrieves a user from the database by their unique ID',
|
|
10
|
+
* tags: ['Users'],
|
|
11
|
+
* deprecated: false
|
|
12
|
+
* })
|
|
13
|
+
* @Get('/:id')
|
|
14
|
+
* getUser(@Param('id') id: string) {}
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function ApiDoc(docs: RouteDocumentation): MethodDecorator;
|
|
18
|
+
/**
|
|
19
|
+
* ApiResponse decorator - documents a possible response for a route
|
|
20
|
+
* Can be used multiple times to document different status codes
|
|
21
|
+
* @param response - Response metadata with status code, description, and schema
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* @ApiResponse({
|
|
25
|
+
* statusCode: 200,
|
|
26
|
+
* description: 'User found',
|
|
27
|
+
* schema: UserSchema
|
|
28
|
+
* })
|
|
29
|
+
* @ApiResponse({
|
|
30
|
+
* statusCode: 404,
|
|
31
|
+
* description: 'User not found'
|
|
32
|
+
* })
|
|
33
|
+
* @Get('/:id')
|
|
34
|
+
* getUser(@Param('id') id: string) {}
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function ApiResponse(response: ResponseMetadata): MethodDecorator;
|
|
38
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../src/decorators/docs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAErE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,eAAe,CAchE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,eAAe,CA6BvE"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ZodSchema } from 'zod';
|
|
3
|
+
import type { GraphQLResolverMetadata, GraphQLFieldMetadata, GraphQLArgumentMetadata } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* @Resolver decorator - Marks a class as a GraphQL resolver
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Resolver()
|
|
10
|
+
* class UserResolver {
|
|
11
|
+
* @Query()
|
|
12
|
+
* async getUser(@Arg('id', z.string()) id: string) {
|
|
13
|
+
* return { id, name: 'John' };
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function Resolver(name?: string): ClassDecorator;
|
|
19
|
+
/**
|
|
20
|
+
* @GQLQuery decorator - Marks a method as a GraphQL query
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* @GQLQuery()
|
|
25
|
+
* async getUser(@Arg('id', z.string()) id: string) {
|
|
26
|
+
* return { id, name: 'John' };
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function GQLQuery(name?: string, options?: {
|
|
31
|
+
description?: string;
|
|
32
|
+
deprecated?: boolean;
|
|
33
|
+
deprecationReason?: string;
|
|
34
|
+
}): MethodDecorator;
|
|
35
|
+
export { GQLQuery as GraphQLQuery };
|
|
36
|
+
/**
|
|
37
|
+
* @GQLMutation decorator - Marks a method as a GraphQL mutation
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* @GQLMutation()
|
|
42
|
+
* async createUser(@Arg('input', CreateUserSchema) input: CreateUserInput) {
|
|
43
|
+
* return { id: '1', ...input };
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function GQLMutation(name?: string, options?: {
|
|
48
|
+
description?: string;
|
|
49
|
+
deprecated?: boolean;
|
|
50
|
+
deprecationReason?: string;
|
|
51
|
+
}): MethodDecorator;
|
|
52
|
+
export { GQLMutation as GraphQLMutation };
|
|
53
|
+
/**
|
|
54
|
+
* @GQLSubscription decorator - Marks a method as a GraphQL subscription
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* @GQLSubscription()
|
|
59
|
+
* async onUserCreated() {
|
|
60
|
+
* return pubsub.asyncIterator('USER_CREATED');
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function GQLSubscription(name?: string, options?: {
|
|
65
|
+
description?: string;
|
|
66
|
+
deprecated?: boolean;
|
|
67
|
+
deprecationReason?: string;
|
|
68
|
+
}): MethodDecorator;
|
|
69
|
+
export { GQLSubscription as GraphQLSubscription };
|
|
70
|
+
/**
|
|
71
|
+
* @Arg decorator - Marks a parameter as a GraphQL argument with validation
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* @Query()
|
|
76
|
+
* async getUser(
|
|
77
|
+
* @Arg('id', z.string().uuid()) id: string,
|
|
78
|
+
* @Arg('includeProfile', z.boolean().optional()) includeProfile?: boolean
|
|
79
|
+
* ) {
|
|
80
|
+
* return { id, name: 'John' };
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function Arg<T extends ZodSchema>(name: string, schema?: T, options?: {
|
|
85
|
+
description?: string;
|
|
86
|
+
defaultValue?: any;
|
|
87
|
+
nullable?: boolean;
|
|
88
|
+
}): ParameterDecorator;
|
|
89
|
+
/**
|
|
90
|
+
* @GQLContext decorator - Injects GraphQL context into a parameter
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* @GQLQuery()
|
|
95
|
+
* async getCurrentUser(@GQLContext() ctx: GraphQLContext) {
|
|
96
|
+
* return ctx.user;
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function GQLContext(): ParameterDecorator;
|
|
101
|
+
export { GQLContext as GraphQLCtx };
|
|
102
|
+
/**
|
|
103
|
+
* Get resolver metadata from a class
|
|
104
|
+
*/
|
|
105
|
+
export declare function getResolverMetadata(target: any): GraphQLResolverMetadata | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Get all field metadata from a resolver class
|
|
108
|
+
*/
|
|
109
|
+
export declare function getFieldsMetadata(target: any): GraphQLFieldMetadata[];
|
|
110
|
+
/**
|
|
111
|
+
* Get field metadata from a specific method
|
|
112
|
+
*/
|
|
113
|
+
export declare function getFieldMetadata(target: any, propertyKey: string): GraphQLFieldMetadata | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Get argument metadata from a method
|
|
116
|
+
*/
|
|
117
|
+
export declare function getArgumentsMetadata(target: any, propertyKey: string): GraphQLArgumentMetadata[];
|
|
118
|
+
/**
|
|
119
|
+
* Check if a class has resolver metadata
|
|
120
|
+
*/
|
|
121
|
+
export declare function hasResolverMetadata(target: any): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Check if a method has field metadata
|
|
124
|
+
*/
|
|
125
|
+
export declare function hasFieldMetadata(target: any, propertyKey: string): boolean;
|
|
126
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/decorators/graphql.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EAExB,MAAM,UA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BpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,IAAI,kBAAkB,CAe/C;AAGD,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,CAAC;AAMpC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,uBAAuB,GAAG,SAAS,CAEpF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,oBAAoB,EAAE,CAErE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAEnG;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAEhG;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAE1E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controller decorator - marks a class as a controller and sets a route prefix
|
|
3
|
+
* @param prefix - The route prefix for all routes in this controller (e.g., '/users')
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* @Controller('/api/users')
|
|
7
|
+
* class UserController {
|
|
8
|
+
* @Get('/:id')
|
|
9
|
+
* getUser() {}
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function Controller(prefix?: string): ClassDecorator;
|
|
14
|
+
/**
|
|
15
|
+
* GET method decorator
|
|
16
|
+
* @param path - The route path (e.g., '/:id' or '/list')
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* @Get('/:id')
|
|
20
|
+
* getUser(@Param('id') id: string) {}
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const Get: (path?: string) => MethodDecorator;
|
|
24
|
+
/**
|
|
25
|
+
* POST method decorator
|
|
26
|
+
* @param path - The route path
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* @Post('/')
|
|
30
|
+
* createUser(@Body(UserSchema) data: User) {}
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const Post: (path?: string) => MethodDecorator;
|
|
34
|
+
/**
|
|
35
|
+
* PUT method decorator
|
|
36
|
+
* @param path - The route path
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* @Put('/:id')
|
|
40
|
+
* updateUser(@Param('id') id: string, @Body(UserSchema) data: User) {}
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const Put: (path?: string) => MethodDecorator;
|
|
44
|
+
/**
|
|
45
|
+
* DELETE method decorator
|
|
46
|
+
* @param path - The route path
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* @Delete('/:id')
|
|
50
|
+
* deleteUser(@Param('id') id: string) {}
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const Delete: (path?: string) => MethodDecorator;
|
|
54
|
+
/**
|
|
55
|
+
* PATCH method decorator
|
|
56
|
+
* @param path - The route path
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* @Patch('/:id')
|
|
60
|
+
* patchUser(@Param('id') id: string, @Body(PartialUserSchema) data: Partial<User>) {}
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const Patch: (path?: string) => MethodDecorator;
|
|
64
|
+
/**
|
|
65
|
+
* ALL method decorator - responds to all HTTP methods
|
|
66
|
+
* @param path - The route path
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* @All('/health')
|
|
70
|
+
* health() { return { status: 'ok' }; }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare const All: (path?: string) => MethodDecorator;
|
|
74
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/decorators/http.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,MAAM,GAAE,MAAW,GAAG,cAAc,CAgB9D;AA0BD;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,UA7BA,MAAM,KAAQ,eA6BiB,CAAC;AAEhD;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,UAxCD,MAAM,KAAQ,eAwCmB,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,UAnDA,MAAM,KAAQ,eAmDiB,CAAC;AAEhD;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,UA9DH,MAAM,KAAQ,eA8DuB,CAAC;AAEtD;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK,UAzEF,MAAM,KAAQ,eAyEqB,CAAC;AAEpD;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,UApFA,MAAM,KAAQ,eAoFiB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Middleware } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* UseMiddleware decorator - applies middleware to a specific route
|
|
4
|
+
*
|
|
5
|
+
* Middleware functions are executed before the route handler.
|
|
6
|
+
* Multiple middleware can be chained and will execute in order.
|
|
7
|
+
*
|
|
8
|
+
* @param middleware - One or more middleware functions to apply
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const authMiddleware: Middleware = async (c, next) => {
|
|
13
|
+
* const token = c.req.header('authorization');
|
|
14
|
+
* if (!token) {
|
|
15
|
+
* return c.json({ error: 'Unauthorized' }, 401);
|
|
16
|
+
* }
|
|
17
|
+
* await next();
|
|
18
|
+
* };
|
|
19
|
+
*
|
|
20
|
+
* class UserController {
|
|
21
|
+
* @Get('/profile')
|
|
22
|
+
* @UseMiddleware(authMiddleware)
|
|
23
|
+
* getProfile() {
|
|
24
|
+
* return { name: 'John', email: 'john@example.com' };
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function UseMiddleware(...middleware: Middleware[]): MethodDecorator;
|
|
30
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/decorators/middleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE,GAAG,eAAe,CAG1E"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ZodSchema } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Body decorator - extracts and validates request body
|
|
4
|
+
* @param schema - Optional Zod schema for validation
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* @Post('/users')
|
|
8
|
+
* createUser(@Body(UserSchema) data: User) {}
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function Body<T extends ZodSchema>(schema?: T): ParameterDecorator;
|
|
12
|
+
/**
|
|
13
|
+
* Query decorator - extracts and validates query parameters
|
|
14
|
+
* @param schema - Optional Zod schema for validation
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* @Get('/users')
|
|
18
|
+
* listUsers(@Query(QuerySchema) query: { page: number, limit: number }) {}
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function Query<T extends ZodSchema>(schema?: T): ParameterDecorator;
|
|
22
|
+
/**
|
|
23
|
+
* Param decorator - extracts route parameters
|
|
24
|
+
* @param name - Optional specific parameter name to extract
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* @Get('/:id')
|
|
28
|
+
* getUser(@Param('id') id: string) {}
|
|
29
|
+
*
|
|
30
|
+
* // Or extract all params
|
|
31
|
+
* @Get('/:userId/posts/:postId')
|
|
32
|
+
* getPost(@Param() params: { userId: string, postId: string }) {}
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function Param(name?: string): ParameterDecorator;
|
|
36
|
+
/**
|
|
37
|
+
* Header decorator - extracts request headers
|
|
38
|
+
* @param name - Optional specific header name to extract
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* @Get('/protected')
|
|
42
|
+
* getProtected(@Header('authorization') auth: string) {}
|
|
43
|
+
*
|
|
44
|
+
* // Or extract all headers
|
|
45
|
+
* @Get('/info')
|
|
46
|
+
* getInfo(@Header() headers: Record<string, string>) {}
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function Header(name?: string): ParameterDecorator;
|
|
50
|
+
/**
|
|
51
|
+
* Cookie decorator - extracts cookies
|
|
52
|
+
* @param name - Optional specific cookie name to extract
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* @Get('/profile')
|
|
56
|
+
* getProfile(@Cookie('session') sessionId: string) {}
|
|
57
|
+
*
|
|
58
|
+
* // Or extract all cookies
|
|
59
|
+
* @Get('/info')
|
|
60
|
+
* getInfo(@Cookie() cookies: Record<string, string>) {}
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function Cookie(name?: string): ParameterDecorator;
|
|
64
|
+
/**
|
|
65
|
+
* Req decorator - injects the raw Hono Request object
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* @Get('/raw')
|
|
69
|
+
* getRaw(@Req() req: Request) {}
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function Req(): ParameterDecorator;
|
|
73
|
+
/**
|
|
74
|
+
* Ctx decorator - injects the Hono Context object
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* @Get('/context')
|
|
78
|
+
* getContext(@Ctx() ctx: Context) {}
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function Ctx(): ParameterDecorator;
|
|
82
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../src/decorators/params.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAIrC;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAaxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAazE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAavD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAaxD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAaxD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,IAAI,kBAAkB,CAYxC;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,IAAI,kBAAkB,CAYxC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ZodSchema } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* @WebSocket decorator - Marks a class as a WebSocket handler
|
|
5
|
+
* @param path - WebSocket endpoint path
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @WebSocket('/ws/chat')
|
|
10
|
+
* class ChatHandler {
|
|
11
|
+
* @OnConnect()
|
|
12
|
+
* handleConnect(connection: WebSocketConnection) {
|
|
13
|
+
* console.log('Client connected');
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function WebSocket(path: string): ClassDecorator;
|
|
19
|
+
/**
|
|
20
|
+
* @OnConnect decorator - Marks a method to be called when a client connects
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* @OnConnect()
|
|
25
|
+
* handleConnect(connection: WebSocketConnection) {
|
|
26
|
+
* connection.send({ type: 'welcome', message: 'Connected!' });
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function OnConnect(): MethodDecorator;
|
|
31
|
+
/**
|
|
32
|
+
* @OnMessage decorator - Marks a method to be called when a message is received
|
|
33
|
+
* @param schema - Optional Zod schema for message validation
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const MessageSchema = z.object({
|
|
38
|
+
* type: z.string(),
|
|
39
|
+
* content: z.string()
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* @OnMessage(MessageSchema)
|
|
43
|
+
* handleMessage(connection: WebSocketConnection, data: z.infer<typeof MessageSchema>) {
|
|
44
|
+
* connection.broadcast(data);
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function OnMessage(schema?: ZodSchema): MethodDecorator;
|
|
49
|
+
/**
|
|
50
|
+
* @OnDisconnect decorator - Marks a method to be called when a client disconnects
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* @OnDisconnect()
|
|
55
|
+
* handleDisconnect(connection: WebSocketConnection) {
|
|
56
|
+
* console.log('Client disconnected');
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function OnDisconnect(): MethodDecorator;
|
|
61
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../../src/decorators/websocket.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGrC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAItD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,IAAI,eAAe,CAO3C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,eAAe,CAQ7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI,eAAe,CAO9C"}
|