Giter Site home page Giter Site logo

nestjsx / nest-emitter Goto Github PK

View Code? Open in Web Editor NEW
178.0 178.0 26.0 2.17 MB

Strongly ๐Ÿ’ช๐Ÿผ Typed Eventemitter Module For Nestjs Framework ๐Ÿฆ

License: MIT License

TypeScript 89.18% Shell 10.82%
eventemitter nestjs typescript utility

nest-emitter's Introduction

Nestjsx Logo

A set of opinionated NestJS extensions and modules

Travis Coverage Status

Packages

  • @nestjsx/common - A set of NestJs decorators, interfaces and configuration for application modules bootstraping.

Tests

npm run test

nest-emitter's People

Contributors

0xflotus avatar bashleigh avatar dependabot[bot] avatar idhard avatar maricn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nest-emitter's Issues

Problem while using nest-emitter in E2E tests

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.

Avoid repetition event emitter module import

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 ?

Release v1.1.1

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. :)

Fail when I execute prestart:prod

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[]];

Testing

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,
}

How to use with Microservices?

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

Please release new version to correctly work with NodeJS v12

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.

Definition issues (Namespace 'NodeJS' has no exported member 'Events')

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 {};

Build error after upgrading node to 12.12.0 version

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;

Unable to add NestEmitterModule in app.module on NestJS v6.0.0

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.