|
8 | 8 | } from './decorator'; |
9 | 9 | import { DEFAULT_MIDDLEWARE, DEFAULT_NORMALIZER } from '../const'; |
10 | 10 | import { Registry } from '../shared/registry'; |
| 11 | +import { MiddlewareRegistry } from '../middleware/middleware.registry'; |
| 12 | +import { ExceptionListenerRegistry } from '../exception-listener/exception-listener.registry'; |
| 13 | +import { NormalizerRegistry } from '../normalizer/normalizer.registry'; |
11 | 14 |
|
12 | 15 | export const registerHandlers = ( |
13 | 16 | moduleRef: ModuleRef, |
@@ -38,32 +41,32 @@ export const registerMiddlewares = ( |
38 | 41 | moduleRef: ModuleRef, |
39 | 42 | discoveryService: DiscoveryService, |
40 | 43 | ) => { |
41 | | - register(moduleRef, discoveryService, Service.MIDDLEWARE_REGISTRY, MESSAGING_MIDDLEWARE_METADATA, 'Middleware'); |
| 44 | + register<MiddlewareRegistry>(moduleRef, discoveryService, Service.MIDDLEWARE_REGISTRY, MESSAGING_MIDDLEWARE_METADATA, 'Middleware'); |
42 | 45 | }; |
43 | 46 |
|
44 | 47 | export const registerMessageNormalizers = ( |
45 | 48 | moduleRef: ModuleRef, |
46 | 49 | discoveryService: DiscoveryService, |
47 | 50 | ) => { |
48 | | - register(moduleRef, discoveryService, Service.MESSAGE_NORMALIZERS_REGISTRY, MESSAGING_NORMALIZER_METADATA, 'MessageNormalizer'); |
| 51 | + register<NormalizerRegistry>(moduleRef, discoveryService, Service.MESSAGE_NORMALIZERS_REGISTRY, MESSAGING_NORMALIZER_METADATA, 'MessageNormalizer'); |
49 | 52 | }; |
50 | 53 |
|
51 | 54 | export const registerExceptionListener = ( |
52 | 55 | moduleRef: ModuleRef, |
53 | 56 | discoveryService: DiscoveryService, |
54 | 57 | ) => { |
55 | | - register(moduleRef, discoveryService, Service.EXCEPTION_LISTENER_REGISTRY, MESSAGING_EXCEPTION_LISTENER_METADATA, 'ExceptionListener'); |
| 58 | + register<ExceptionListenerRegistry>(moduleRef, discoveryService, Service.EXCEPTION_LISTENER_REGISTRY, MESSAGING_EXCEPTION_LISTENER_METADATA, 'ExceptionListener'); |
56 | 59 | }; |
57 | 60 |
|
58 | | -const register = ( |
| 61 | +const register = <T extends Registry<object>>( |
59 | 62 | moduleRef: ModuleRef, |
60 | 63 | discoveryService: DiscoveryService, |
61 | 64 | registryProvider: string, |
62 | 65 | decoratorMetadata: string, |
63 | 66 | name: string, |
64 | 67 | ) => { |
65 | 68 | const exceptions = [DEFAULT_NORMALIZER, DEFAULT_MIDDLEWARE]; |
66 | | - const registry: Registry<any> = moduleRef.get( |
| 69 | + const registry: Registry<T> = moduleRef.get( |
67 | 70 | registryProvider, |
68 | 71 | ); |
69 | 72 | const logger: MessagingLogger = moduleRef.get(Service.LOGGER); |
|
0 commit comments