A set of opinionated NestJS extensions and modules
- @nestjsx/common - A set of NestJs decorators, interfaces and configuration for application modules bootstraping.
npm run test
Strongly ๐ช๐ผ Typed Eventemitter Module For Nestjs Framework ๐ฆ
License: MIT License
A set of opinionated NestJS extensions and modules
npm run test
Hi,
thanks for the great package!
I would love to use it in combination with the Microservices Event Pattern. Do you see a way how this can be done?
Best
Philipp
It could be the same issue with NestJS v6.0.0 update, but here is error message I got when start nestjs app.
[Nest] 77452 - 04/04/2019, 3:33 PM [NestFactory] Starting Nest application...
[Nest] 77452 - 04/04/2019, 3:33 PM [ExceptionHandler] Nest cannot export a provider/module that is not a part of the currently processed module (NestEmitterModule). Please verify whether each exported unit is available in this particular context. +17ms
Error: Nest cannot export a provider/module that is not a part of the currently processed module (NestEmitterModule). Please verify whether each exported unit is available in this particular context.
at Module.validateExportedProvider (/opt/vrs/eslnest/node_modules/@nestjs/core/injector/module.js:224:19)
at Module.addCustomExportedProvider (/opt/vrs/eslnest/node_modules/@nestjs/core/injector/module.js:208:43)
at Module.addExportedProvider (/opt/vrs/eslnest/node_modules/@nestjs/core/injector/module.js:194:25)
at NestContainer.addExportedProvider (/opt/vrs/eslnest/node_modules/@nestjs/core/injector/container.js:112:16)
at DependenciesScanner.insertExportedProvider (/opt/vrs/eslnest/node_modules/@nestjs/core/scanner.js:170:24)
at exports.forEach.exportedProvider (/opt/vrs/eslnest/node_modules/@nestjs/core/scanner.js:101:50)
at Array.forEach ()
at DependenciesScanner.reflectExports (/opt/vrs/eslnest/node_modules/@nestjs/core/scanner.js:101:17)
at DependenciesScanner.scanModulesForDependencies (/opt/vrs/eslnest/node_modules/@nestjs/core/scanner.js:54:18)
at process._tickCallback (internal/process/next_tick.js:68:7)
1: 0x8dc1c0 node::Abort() [node]
2: 0x96e1a9 [node]
3: 0xb5e7cf [node]
4: 0xb5f339 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
5: 0x2567b1cdbe1d
Aborted
Please refer to this link nestjs/nest#1010
I create a service function outside of nest for more simple unit testing. How can I emit events from this function instead of a nestjs class?
npm run prestart:prod
[email protected] prestart:prod /home/develop/backend
tsc
node_modules/nest-emitter/strong-emitter.d.ts:17:82 - error TS1110: Type expected.
17 declare type ListenerType = [T] extends [(...args: infer U) => any] ? U : [T, ...any[]];
The latest master branch has a fix for the types that I would love to have for my project - unfortunately I can't just cleanly import this module from GitHub because of TypeScript.
@shekohex could you push a new version to npm? Would be very appreciated. :)
Hi,
I would like to know how can I inject the emitter in a custom provider
Thank you
Hello, how i can import this emitter provider on unit test?
Nest can't resolve dependencies of the GameController (?, GameService). Please make sure that the argument at index [0] is available in the current context.
On first argument i have:
@InjectEventEmitter() private readonly gameEmitter: GameEventEmitter
May be i can do this using EVENT_EMITTER_TOKEN
for custom provider, it would be nice then to export it.
It works for me:
import { EventEmitter } from 'events';
const EVENT_EMITTER_TOKEN = '__event_emitter__';
{
provide: EVENT_EMITTER_TOKEN,
useValue: EventEmitter,
}
Why event emitter need to be imported each events.
The event emitter module already imported on app.module.ts
(import { EventEmitter } from 'event'
), then why i should import it back to (eg: payment.event.ts
)
Is this strong typed case ?
this.emitter.on('notification', async msg => await this.onNotification(msg));
Can I just do:
this.emitter.on('notification', this.onNotification);
I'm not sure what benefit the async
offers?
Hello I get following error when builiding project
node_modules/nest-emitter/nest-emitter.module.d.ts:3:35 - error TS2694: Namespace 'NodeJS' has no exported member 'Events'.
declare type NestEmitter = NodeJS.Events;
Is there a way to inject multiple event emitters in a single controller?
Hi, i have a Definition issues.
And i'm using nest v6
node_modules/nest-emitter/nest-emitter.module.d.ts:3:35 - error TS2694: Namespace 'NodeJS' has no exported member 'Events'.
3 declare type NestEmitter = NodeJS.Events
import {EventEmitter} from 'events';
/// <reference types="node" />
import { DynamicModule } from '@nestjs/common';
declare type NestEmitter = NodeJS.Events;
export declare class NestEmitterModule {
static forRoot(emitter: NestEmitter): DynamicModule;
}
export {};
So i'm replace that. it works fine.
import {EventEmitter} from 'events';
/// <reference types="node" />
import { DynamicModule } from '@nestjs/common';
declare type NestEmitter = EventEmitter;
export declare class NestEmitterModule {
static forRoot(emitter: NestEmitter): DynamicModule;
}
export {};
Hello,
Can someone provide a way to .overrideProvider
/ .useValue
while usng nest-emitter.
I got an error in e2e tests when testing service that has @InjectEventEmitter()
inside.
This is the error:
Nest can't resolve dependencies of the ConfigurationService (ConfigurationEntityRepository, ?, Logger). Please make sure that the argument __event_emitter__ at index [1] is available in the ConfigurationModule context.
After upgrade to NodeJS v12, nest-emitter no longer buildable.
node_modules/nest-emitter/nest-emitter.module.d.ts(3,35): error TS2694: Namespace 'NodeJS' has no exported member 'Events'.
#13 fixed this issue and already merged.
Please release a new version.
Could you please update dependencies to nestjs version 6.0.0? Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.