@veloxts/router 0.6.56 → 0.6.57
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 +9 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +25 -0
- package/dist/providers.d.ts +90 -0
- package/dist/providers.js +145 -0
- package/dist/tokens.d.ts +107 -0
- package/dist/tokens.js +78 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -59,3 +59,25 @@ export type { ContractDefinition, ContractEntry, HttpMethodRoute, InferContract,
|
|
|
59
59
|
export { defineContract, defineRoutes } from './contracts.js';
|
|
60
60
|
export type { ServeOptions } from './expose.js';
|
|
61
61
|
export { serve } from './expose.js';
|
|
62
|
+
/**
|
|
63
|
+
* DI tokens and providers for @veloxts/router
|
|
64
|
+
*
|
|
65
|
+
* Use these to integrate router services with the @veloxts/core DI container.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { Container } from '@veloxts/core';
|
|
70
|
+
* import { registerRouterProviders, TRPC_INSTANCE, APP_ROUTER } from '@veloxts/router';
|
|
71
|
+
*
|
|
72
|
+
* const container = new Container();
|
|
73
|
+
* registerRouterProviders(container, {
|
|
74
|
+
* procedures: [userProcedures, postProcedures],
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
78
|
+
* const router = container.resolve(APP_ROUTER);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export { appRouterProvider, registerRouterProviders, trpcInstanceProvider, trpcPluginOptionsProvider, } from './providers.js';
|
|
82
|
+
export type { RestAdapterConfig, RouterConfig } from './tokens.js';
|
|
83
|
+
export { APP_ROUTER, PROCEDURE_COLLECTIONS, REST_ADAPTER_CONFIG, ROUTER_CONFIG, TRPC_INSTANCE, TRPC_PLUGIN_OPTIONS, } from './tokens.js';
|
package/dist/index.js
CHANGED
|
@@ -61,3 +61,28 @@ appRouter, buildTRPCRouter, createTRPCContextFactory, registerTRPCPlugin, trpc,
|
|
|
61
61
|
export { DiscoveryError, DiscoveryErrorCode, directoryNotFound, discoverProcedures, discoverProceduresVerbose, fileLoadError, invalidExport, invalidFileType, isDiscoveryError, noProceduresFound, permissionDenied, } from './discovery/index.js';
|
|
62
62
|
export { defineContract, defineRoutes } from './contracts.js';
|
|
63
63
|
export { serve } from './expose.js';
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// Dependency Injection
|
|
66
|
+
// ============================================================================
|
|
67
|
+
/**
|
|
68
|
+
* DI tokens and providers for @veloxts/router
|
|
69
|
+
*
|
|
70
|
+
* Use these to integrate router services with the @veloxts/core DI container.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { Container } from '@veloxts/core';
|
|
75
|
+
* import { registerRouterProviders, TRPC_INSTANCE, APP_ROUTER } from '@veloxts/router';
|
|
76
|
+
*
|
|
77
|
+
* const container = new Container();
|
|
78
|
+
* registerRouterProviders(container, {
|
|
79
|
+
* procedures: [userProcedures, postProcedures],
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
83
|
+
* const router = container.resolve(APP_ROUTER);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
// Provider exports - factory functions for registering services
|
|
87
|
+
export { appRouterProvider, registerRouterProviders, trpcInstanceProvider, trpcPluginOptionsProvider, } from './providers.js';
|
|
88
|
+
export { APP_ROUTER, PROCEDURE_COLLECTIONS, REST_ADAPTER_CONFIG, ROUTER_CONFIG, TRPC_INSTANCE, TRPC_PLUGIN_OPTIONS, } from './tokens.js';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DI Providers for @veloxts/router
|
|
3
|
+
*
|
|
4
|
+
* Factory provider functions for registering router services with the DI container.
|
|
5
|
+
* These providers allow services to be managed by the container for testability and flexibility.
|
|
6
|
+
*
|
|
7
|
+
* @module router/providers
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Container } from '@veloxts/core';
|
|
12
|
+
* import { registerRouterProviders, TRPC_INSTANCE, APP_ROUTER } from '@veloxts/router';
|
|
13
|
+
*
|
|
14
|
+
* const container = new Container();
|
|
15
|
+
* registerRouterProviders(container, {
|
|
16
|
+
* procedures: [userProcedures, postProcedures],
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
20
|
+
* const router = container.resolve(APP_ROUTER);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { type Container, type FactoryProvider } from '@veloxts/core';
|
|
24
|
+
import type { RouterConfig } from './tokens.js';
|
|
25
|
+
import type { AnyRouter, TRPCInstance, TRPCPluginOptions } from './trpc/index.js';
|
|
26
|
+
/**
|
|
27
|
+
* Creates a factory provider for the tRPC instance
|
|
28
|
+
*
|
|
29
|
+
* The tRPC instance is the foundation for building type-safe routers.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* container.register(trpcInstanceProvider());
|
|
34
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function trpcInstanceProvider(): FactoryProvider<TRPCInstance>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a factory provider for the app router
|
|
40
|
+
*
|
|
41
|
+
* Requires TRPC_INSTANCE and PROCEDURE_COLLECTIONS to be registered.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* container.register({ provide: PROCEDURE_COLLECTIONS, useValue: [userProcedures] });
|
|
46
|
+
* container.register(trpcInstanceProvider());
|
|
47
|
+
* container.register(appRouterProvider());
|
|
48
|
+
*
|
|
49
|
+
* const router = container.resolve(APP_ROUTER);
|
|
50
|
+
* export type AppRouter = typeof router;
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function appRouterProvider(): FactoryProvider<AnyRouter>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a factory provider for tRPC plugin options
|
|
56
|
+
*
|
|
57
|
+
* Requires APP_ROUTER and ROUTER_CONFIG to be registered.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const options = container.resolve(TRPC_PLUGIN_OPTIONS);
|
|
62
|
+
* await registerTRPCPlugin(server, options);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function trpcPluginOptionsProvider(): FactoryProvider<TRPCPluginOptions>;
|
|
66
|
+
/**
|
|
67
|
+
* Registers core router providers with a container
|
|
68
|
+
*
|
|
69
|
+
* This registers the tRPC instance and app router for DI-enabled routing.
|
|
70
|
+
*
|
|
71
|
+
* @param container - The DI container to register providers with
|
|
72
|
+
* @param config - Router configuration with procedure collections
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { Container } from '@veloxts/core';
|
|
77
|
+
* import { registerRouterProviders, TRPC_INSTANCE, APP_ROUTER } from '@veloxts/router';
|
|
78
|
+
*
|
|
79
|
+
* const container = new Container();
|
|
80
|
+
* registerRouterProviders(container, {
|
|
81
|
+
* procedures: [userProcedures, postProcedures],
|
|
82
|
+
* apiPrefix: '/api',
|
|
83
|
+
* rpcPrefix: '/trpc',
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
87
|
+
* const router = container.resolve(APP_ROUTER);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function registerRouterProviders(container: Container, config?: RouterConfig): void;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DI Providers for @veloxts/router
|
|
3
|
+
*
|
|
4
|
+
* Factory provider functions for registering router services with the DI container.
|
|
5
|
+
* These providers allow services to be managed by the container for testability and flexibility.
|
|
6
|
+
*
|
|
7
|
+
* @module router/providers
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Container } from '@veloxts/core';
|
|
12
|
+
* import { registerRouterProviders, TRPC_INSTANCE, APP_ROUTER } from '@veloxts/router';
|
|
13
|
+
*
|
|
14
|
+
* const container = new Container();
|
|
15
|
+
* registerRouterProviders(container, {
|
|
16
|
+
* procedures: [userProcedures, postProcedures],
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
20
|
+
* const router = container.resolve(APP_ROUTER);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { Scope } from '@veloxts/core';
|
|
24
|
+
import { APP_ROUTER, PROCEDURE_COLLECTIONS, REST_ADAPTER_CONFIG, ROUTER_CONFIG, TRPC_INSTANCE, TRPC_PLUGIN_OPTIONS, } from './tokens.js';
|
|
25
|
+
import { appRouter, trpc } from './trpc/index.js';
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Core Router Providers
|
|
28
|
+
// ============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Creates a factory provider for the tRPC instance
|
|
31
|
+
*
|
|
32
|
+
* The tRPC instance is the foundation for building type-safe routers.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* container.register(trpcInstanceProvider());
|
|
37
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function trpcInstanceProvider() {
|
|
41
|
+
return {
|
|
42
|
+
provide: TRPC_INSTANCE,
|
|
43
|
+
useFactory: () => trpc(),
|
|
44
|
+
inject: [],
|
|
45
|
+
scope: Scope.SINGLETON,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a factory provider for the app router
|
|
50
|
+
*
|
|
51
|
+
* Requires TRPC_INSTANCE and PROCEDURE_COLLECTIONS to be registered.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* container.register({ provide: PROCEDURE_COLLECTIONS, useValue: [userProcedures] });
|
|
56
|
+
* container.register(trpcInstanceProvider());
|
|
57
|
+
* container.register(appRouterProvider());
|
|
58
|
+
*
|
|
59
|
+
* const router = container.resolve(APP_ROUTER);
|
|
60
|
+
* export type AppRouter = typeof router;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function appRouterProvider() {
|
|
64
|
+
return {
|
|
65
|
+
provide: APP_ROUTER,
|
|
66
|
+
useFactory: (t, collections) => appRouter(t, collections),
|
|
67
|
+
inject: [TRPC_INSTANCE, PROCEDURE_COLLECTIONS],
|
|
68
|
+
scope: Scope.SINGLETON,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Creates a factory provider for tRPC plugin options
|
|
73
|
+
*
|
|
74
|
+
* Requires APP_ROUTER and ROUTER_CONFIG to be registered.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const options = container.resolve(TRPC_PLUGIN_OPTIONS);
|
|
79
|
+
* await registerTRPCPlugin(server, options);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export function trpcPluginOptionsProvider() {
|
|
83
|
+
return {
|
|
84
|
+
provide: TRPC_PLUGIN_OPTIONS,
|
|
85
|
+
useFactory: (router, config) => ({
|
|
86
|
+
prefix: config.rpcPrefix ?? '/trpc',
|
|
87
|
+
router,
|
|
88
|
+
}),
|
|
89
|
+
inject: [APP_ROUTER, ROUTER_CONFIG],
|
|
90
|
+
scope: Scope.SINGLETON,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Bulk Registration Helpers
|
|
95
|
+
// ============================================================================
|
|
96
|
+
/**
|
|
97
|
+
* Registers core router providers with a container
|
|
98
|
+
*
|
|
99
|
+
* This registers the tRPC instance and app router for DI-enabled routing.
|
|
100
|
+
*
|
|
101
|
+
* @param container - The DI container to register providers with
|
|
102
|
+
* @param config - Router configuration with procedure collections
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* import { Container } from '@veloxts/core';
|
|
107
|
+
* import { registerRouterProviders, TRPC_INSTANCE, APP_ROUTER } from '@veloxts/router';
|
|
108
|
+
*
|
|
109
|
+
* const container = new Container();
|
|
110
|
+
* registerRouterProviders(container, {
|
|
111
|
+
* procedures: [userProcedures, postProcedures],
|
|
112
|
+
* apiPrefix: '/api',
|
|
113
|
+
* rpcPrefix: '/trpc',
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
117
|
+
* const router = container.resolve(APP_ROUTER);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export function registerRouterProviders(container, config = {}) {
|
|
121
|
+
// Register config
|
|
122
|
+
container.register({
|
|
123
|
+
provide: ROUTER_CONFIG,
|
|
124
|
+
useValue: config,
|
|
125
|
+
});
|
|
126
|
+
// Register procedure collections
|
|
127
|
+
container.register({
|
|
128
|
+
provide: PROCEDURE_COLLECTIONS,
|
|
129
|
+
useValue: config.procedures ?? [],
|
|
130
|
+
});
|
|
131
|
+
// Register REST adapter config
|
|
132
|
+
container.register({
|
|
133
|
+
provide: REST_ADAPTER_CONFIG,
|
|
134
|
+
useValue: {
|
|
135
|
+
prefix: config.apiPrefix ?? '/api',
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
// Register tRPC instance provider
|
|
139
|
+
container.register(trpcInstanceProvider());
|
|
140
|
+
// Only register app router if procedures are provided
|
|
141
|
+
if (config.procedures && config.procedures.length > 0) {
|
|
142
|
+
container.register(appRouterProvider());
|
|
143
|
+
container.register(trpcPluginOptionsProvider());
|
|
144
|
+
}
|
|
145
|
+
}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DI Tokens for @veloxts/router
|
|
3
|
+
*
|
|
4
|
+
* Symbol-based tokens for type-safe dependency injection.
|
|
5
|
+
* These tokens allow router services to be registered, resolved, and mocked via the DI container.
|
|
6
|
+
*
|
|
7
|
+
* @module router/tokens
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Container } from '@veloxts/core';
|
|
12
|
+
* import { TRPC_INSTANCE, trpcInstanceProvider, registerRouterProviders } from '@veloxts/router';
|
|
13
|
+
*
|
|
14
|
+
* const container = new Container();
|
|
15
|
+
* registerRouterProviders(container);
|
|
16
|
+
*
|
|
17
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import type { TRPCPluginOptions } from './trpc/index.js';
|
|
21
|
+
import type { ProcedureCollection } from './types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Router configuration for DI registration
|
|
24
|
+
*/
|
|
25
|
+
export interface RouterConfig {
|
|
26
|
+
/**
|
|
27
|
+
* Procedure collections to register
|
|
28
|
+
*/
|
|
29
|
+
procedures?: ProcedureCollection[];
|
|
30
|
+
/**
|
|
31
|
+
* REST API prefix
|
|
32
|
+
* @default '/api'
|
|
33
|
+
*/
|
|
34
|
+
apiPrefix?: string;
|
|
35
|
+
/**
|
|
36
|
+
* tRPC endpoint prefix
|
|
37
|
+
* @default '/trpc'
|
|
38
|
+
*/
|
|
39
|
+
rpcPrefix?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* REST adapter configuration for DI
|
|
43
|
+
*/
|
|
44
|
+
export interface RestAdapterConfig {
|
|
45
|
+
/**
|
|
46
|
+
* API prefix for routes
|
|
47
|
+
* @default '/api'
|
|
48
|
+
*/
|
|
49
|
+
prefix?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* tRPC instance token
|
|
53
|
+
*
|
|
54
|
+
* The tRPC instance used for building routers and procedures.
|
|
55
|
+
* This is created by `trpc()` and provides the base for procedure definitions.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
60
|
+
* const router = t.router({
|
|
61
|
+
* hello: t.procedure.query(() => 'Hello World'),
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare const TRPC_INSTANCE: import("@veloxts/core").SymbolToken<import("@trpc/server").TRPCRootObject<import("@veloxts/core").BaseContext, object, import("@trpc/server").TRPCRuntimeConfigOptions<import("@veloxts/core").BaseContext, object>, {
|
|
66
|
+
ctx: import("@veloxts/core").BaseContext;
|
|
67
|
+
meta: object;
|
|
68
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
69
|
+
transformer: false;
|
|
70
|
+
}>>;
|
|
71
|
+
/**
|
|
72
|
+
* App router token
|
|
73
|
+
*
|
|
74
|
+
* The merged tRPC router from all procedure collections.
|
|
75
|
+
* This is the router exported for type inference on the client.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const router = container.resolve(APP_ROUTER);
|
|
80
|
+
* export type AppRouter = typeof router;
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare const APP_ROUTER: import("@veloxts/core").SymbolToken<import("@trpc/server").AnyRouter>;
|
|
84
|
+
/**
|
|
85
|
+
* Router configuration token
|
|
86
|
+
*
|
|
87
|
+
* Contains router settings including procedure collections and prefixes.
|
|
88
|
+
*/
|
|
89
|
+
export declare const ROUTER_CONFIG: import("@veloxts/core").SymbolToken<RouterConfig>;
|
|
90
|
+
/**
|
|
91
|
+
* REST adapter configuration token
|
|
92
|
+
*
|
|
93
|
+
* Configuration for the REST adapter including prefix settings.
|
|
94
|
+
*/
|
|
95
|
+
export declare const REST_ADAPTER_CONFIG: import("@veloxts/core").SymbolToken<RestAdapterConfig>;
|
|
96
|
+
/**
|
|
97
|
+
* tRPC plugin options token
|
|
98
|
+
*
|
|
99
|
+
* Configuration for the tRPC Fastify plugin including prefix and router.
|
|
100
|
+
*/
|
|
101
|
+
export declare const TRPC_PLUGIN_OPTIONS: import("@veloxts/core").SymbolToken<TRPCPluginOptions>;
|
|
102
|
+
/**
|
|
103
|
+
* Procedure collections token
|
|
104
|
+
*
|
|
105
|
+
* Array of procedure collections to register with the router.
|
|
106
|
+
*/
|
|
107
|
+
export declare const PROCEDURE_COLLECTIONS: import("@veloxts/core").SymbolToken<ProcedureCollection<import("./types.js").ProcedureRecord>[]>;
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DI Tokens for @veloxts/router
|
|
3
|
+
*
|
|
4
|
+
* Symbol-based tokens for type-safe dependency injection.
|
|
5
|
+
* These tokens allow router services to be registered, resolved, and mocked via the DI container.
|
|
6
|
+
*
|
|
7
|
+
* @module router/tokens
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Container } from '@veloxts/core';
|
|
12
|
+
* import { TRPC_INSTANCE, trpcInstanceProvider, registerRouterProviders } from '@veloxts/router';
|
|
13
|
+
*
|
|
14
|
+
* const container = new Container();
|
|
15
|
+
* registerRouterProviders(container);
|
|
16
|
+
*
|
|
17
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import { token } from '@veloxts/core';
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Core Router Tokens
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* tRPC instance token
|
|
26
|
+
*
|
|
27
|
+
* The tRPC instance used for building routers and procedures.
|
|
28
|
+
* This is created by `trpc()` and provides the base for procedure definitions.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const t = container.resolve(TRPC_INSTANCE);
|
|
33
|
+
* const router = t.router({
|
|
34
|
+
* hello: t.procedure.query(() => 'Hello World'),
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const TRPC_INSTANCE = token.symbol('TRPC_INSTANCE');
|
|
39
|
+
/**
|
|
40
|
+
* App router token
|
|
41
|
+
*
|
|
42
|
+
* The merged tRPC router from all procedure collections.
|
|
43
|
+
* This is the router exported for type inference on the client.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const router = container.resolve(APP_ROUTER);
|
|
48
|
+
* export type AppRouter = typeof router;
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export const APP_ROUTER = token.symbol('APP_ROUTER');
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Configuration Tokens
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* Router configuration token
|
|
57
|
+
*
|
|
58
|
+
* Contains router settings including procedure collections and prefixes.
|
|
59
|
+
*/
|
|
60
|
+
export const ROUTER_CONFIG = token.symbol('ROUTER_CONFIG');
|
|
61
|
+
/**
|
|
62
|
+
* REST adapter configuration token
|
|
63
|
+
*
|
|
64
|
+
* Configuration for the REST adapter including prefix settings.
|
|
65
|
+
*/
|
|
66
|
+
export const REST_ADAPTER_CONFIG = token.symbol('REST_ADAPTER_CONFIG');
|
|
67
|
+
/**
|
|
68
|
+
* tRPC plugin options token
|
|
69
|
+
*
|
|
70
|
+
* Configuration for the tRPC Fastify plugin including prefix and router.
|
|
71
|
+
*/
|
|
72
|
+
export const TRPC_PLUGIN_OPTIONS = token.symbol('TRPC_PLUGIN_OPTIONS');
|
|
73
|
+
/**
|
|
74
|
+
* Procedure collections token
|
|
75
|
+
*
|
|
76
|
+
* Array of procedure collections to register with the router.
|
|
77
|
+
*/
|
|
78
|
+
export const PROCEDURE_COLLECTIONS = token.symbol('PROCEDURE_COLLECTIONS');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veloxts/router",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.57",
|
|
4
4
|
"description": "Procedure definitions with tRPC and REST routing for VeloxTS framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@trpc/server": "11.8.0",
|
|
37
37
|
"fastify": "5.6.2",
|
|
38
|
-
"@veloxts/
|
|
39
|
-
"@veloxts/
|
|
38
|
+
"@veloxts/core": "0.6.57",
|
|
39
|
+
"@veloxts/validation": "0.6.57"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@vitest/coverage-v8": "4.0.16",
|