juicycleff / nestjs-event-store

NestJS CQRS module for EventStore.org. It requires @nestjs/cqrs
https://xraph.com
MIT License
199 stars 29 forks source link

registerFeatureAsync Injects Incorrect Eventstore Options #8

Closed tadejgasparovic closed 4 years ago

tadejgasparovic commented 4 years ago

When calling EventStoreModule.registerFeatureAsync() , it injects NEST_EVENTSTORE_OPTION provider instead of NEST_EVENTSTORE_FEATURE_OPTION which ends up crashing Nest injector.

The following shim works for me:

const _registerFeatureAsync = Reflect.get(EventStoreModule, 'registerFeatureAsync');
Reflect.set(EventStoreModule, 'registerFeatureAsync', function () {
    const module = _registerFeatureAsync.apply(null, arguments);
    module.imports[0].providers.find(p => (
        p.provide === ProvidersConstants.EVENT_STORE_STREAM_CONFIG_PROVIDER
    )).inject = [NEST_EVENTSTORE_FEATURE_OPTION];
    return module;
});
juicycleff commented 4 years ago

@tadejgasparovic thanks for pointing out that bug, I will fix it and make a release. Thanks