Skip to content

Commit 285528d

Browse files
author
kamil.mysliwiec
committed
Issue nestjs#45 fix - export custom component
1 parent cf2d641 commit 285528d

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

example/modules/users/users.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ChatGateway } from './chat.gateway';
88
@Module({
99
controllers: [ UsersController ],
1010
components: [
11-
{ provide: 'UsersService', useClass: UsersService },
11+
UsersService,
1212
ChatGateway,
1313
],
1414
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nest.js",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Modern, fast, powerful node.js web framework",
55
"main": "index.js",
66
"scripts": {

src/core/injector/module.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class Module {
138138
});
139139
}
140140

141-
public addCustomFactory(component: CustomFactory){
141+
public addCustomFactory(component: CustomFactory) {
142142
const { provide, name, useFactory: factory, inject } = component;
143143
this._components.set(name, {
144144
name,
@@ -150,13 +150,21 @@ export class Module {
150150
});
151151
}
152152

153-
public addExportedComponent(exportedComponent: Metatype<Injectable>) {
153+
public addExportedComponent(exportedComponent: ComponentMetatype) {
154+
if (this.isCustomComponent(exportedComponent)) {
155+
this.addCustomExportedComponent(exportedComponent);
156+
return;
157+
}
154158
if (!this._components.get(exportedComponent.name)) {
155159
throw new UnknownExportException(exportedComponent.name);
156160
}
157161
this._exports.add(exportedComponent.name);
158162
}
159163

164+
public addCustomExportedComponent(exportedComponent: CustomFactory | CustomValue | CustomClass) {
165+
this._exports.add(exportedComponent.provide);
166+
}
167+
160168
public addRoute(route: Metatype<Controller>) {
161169
this._routes.set(route.name, {
162170
name: route.name,

0 commit comments

Comments
 (0)