Nest: (feature): Default provider

Created on 4 Nov 2017  Â·  3Comments  Â·  Source: nestjs/nest

Hi my name is ..., who? My name is ..., what? My name is Au Au Au Automagic.

I just realize, that we can create Auto-loader, I don't know if you guys wrote in php before, but there was a nice feature killer called Autoloading Classes http://php.net/manual/en/language.oop5.autoload.php

But now, we have nest and @Inject property decorator, so my goal is to have a one or more default providers, that will be called after none of the providers match the required injected.

Lets assume that we have kind of this situation:

    constructor(@Inject('UserRepositoryToken') protected repository: Repository<UserEntity>) {
    }

But we might don't wanna for each entity repo define new provider, because all they will different only by Entity class, ¯\_(ツ)_/¯

So then, how about define a default provider, that will handle all of the our cases? Kind of nested Provider Factory.

All 3 comments

+1

El 4 nov. 2017 17:31, "cojack" notifications@github.com escribió:

Hi my name is ..., who? My name is ..., what? My name is Au Au Au Automagic.

I just realize, that we can create Auto-loader, I don't know if you guys
wrote in php before, but there was a nice feature killer called Autoloading
Classes http://php.net/manual/en/language.oop5.autoload.php

But now, we have nest and @Inject https://github.com/inject property
decorator, so my goal is to have a one or more default providers, that will
be called after none of the providers match the required injected.

Lets assume that we have kind of this situation:

constructor(@Inject('UserRepositoryToken') protected repository:

Repository) {
}

But we might don't wanna for each entity repo define new provider, because
all they will different only by Entity class, ¯_(ツ)_/¯

So then, how about define a default provider, that will handle all of the
our cases? Kind of nested Provider Factory.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/nestjs/nest/issues/227, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABr3CZCPuTViiW84DvgpIR5Mp-8BwbVeks5szMm_gaJpZM4QSJgj
.

Hi @cojack,
Do you have any idea how the API should look like?

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marshall007 picture marshall007  Â·  3Comments

artaommahe picture artaommahe  Â·  3Comments

KamGor picture KamGor  Â·  3Comments

breitsmiley picture breitsmiley  Â·  3Comments

kiwikern picture kiwikern  Â·  3Comments