Skip to content

Commit

Permalink
examples(@nestjs) update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Dec 30, 2017
1 parent d2875bf commit 13ddd03
Show file tree
Hide file tree
Showing 24 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/01-cats-app/e2e/cats/cats.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Cats', () => {

beforeAll(async () => {
const module = await Test.createTestingModule({
modules: [CatsModule],
imports: [CatsModule],
})
.overrideComponent(CatsService)
.useValue(catsService)
Expand Down
2 changes: 1 addition & 1 deletion examples/01-cats-app/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CatsModule } from './cats/cats.module';
import { CatsController } from './cats/cats.controller';

@Module({
modules: [CatsModule],
imports: [CatsModule],
})
export class ApplicationModule implements NestModule {
configure(consumer: MiddlewaresConsumer): void {
Expand Down
2 changes: 1 addition & 1 deletion examples/02-gateways/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Module } from '@nestjs/common';
import { EventsModule } from './events/events.module';

@Module({
modules: [EventsModule],
imports: [EventsModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/03-microservices/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Module } from '@nestjs/common';
import { MathModule } from './math/math.module';

@Module({
modules: [MathModule],
imports: [MathModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/04-injector/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { CoreModule } from './core/core.module';
import { FeatureModule } from './feature/feature.module';

@Module({
modules: [FeatureModule],
imports: [FeatureModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/04-injector/src/modules/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ContextService } from './context.service';
import { FeatureModule } from '../feature/feature.module';

@Module({
modules: [CommonModule],
imports: [CommonModule],
components: [CoreService, ContextService],
exports: [CommonModule],
})
Expand Down
2 changes: 1 addition & 1 deletion examples/04-injector/src/modules/feature/feature.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FeatureService } from './feature.service';
import { CoreModule } from '../core/core.module';

@Module({
modules: [CoreModule],
imports: [CoreModule],
components: [FeatureService],
})
export class FeatureModule {}
2 changes: 1 addition & 1 deletion examples/05-sql-typeorm/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { PhotoModule } from './photo/photo.module';
import { Photo } from './photo/photo.entity';

@Module({
modules: [TypeOrmModule.forRoot([Photo]), PhotoModule],
imports: [TypeOrmModule.forRoot([Photo]), PhotoModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/06-mongoose/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Module } from '@nestjs/common';
import { CatsModule } from './cats/cats.module';

@Module({
modules: [CatsModule],
imports: [CatsModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/06-mongoose/src/modules/cats/cats.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { catsProviders } from './cats.providers';
import { DatabaseModule } from '../database/database.module';

@Module({
modules: [DatabaseModule],
imports: [DatabaseModule],
controllers: [CatsController],
components: [CatsService, ...catsProviders],
})
Expand Down
2 changes: 1 addition & 1 deletion examples/07-sequelize/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Module } from '@nestjs/common';
import { CatsModule } from './cats/cats.module';

@Module({
modules: [CatsModule],
imports: [CatsModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/07-sequelize/src/modules/cats/cats.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { catsProviders } from './cats.providers';
import { DatabaseModule } from '../database/database.module';

@Module({
modules: [DatabaseModule],
imports: [DatabaseModule],
controllers: [CatsController],
components: [CatsService, ...catsProviders],
})
Expand Down
2 changes: 1 addition & 1 deletion examples/08-passport/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Module } from '@nestjs/common';
import { AuthModule } from './auth/auth.module';

@Module({
modules: [AuthModule],
imports: [AuthModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/09-babel-example/src/modules/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { CatsModule } from './cats/cats.module';
import { CatsController } from './cats/cats.controller';

@Module({
modules: [CatsModule],
imports: [CatsModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/10-mockgoose/e2e/cats/cats.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Cats', () => {

beforeAll(async () => {
const module = await Test.createTestingModule({
modules: [CatsModule],
imports: [CatsModule],
}).compile();

const app = module.createNestApplication(server);
Expand Down
2 changes: 1 addition & 1 deletion examples/10-mockgoose/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Module } from '@nestjs/common';
import { CatsModule } from './cats/cats.module';

@Module({
modules: [CatsModule],
imports: [CatsModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/10-mockgoose/src/modules/cats/cats.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { catsProviders } from './cats.providers';
import { DatabaseModule } from '../database/database.module';

@Module({
modules: [DatabaseModule],
imports: [DatabaseModule],
controllers: [CatsController],
components: [CatsService, ...catsProviders],
})
Expand Down
2 changes: 1 addition & 1 deletion examples/11-swagger/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { CatsModule } from './cats/cats.module';
import { CatsController } from './cats/cats.controller';

@Module({
modules: [CatsModule],
imports: [CatsModule],
})
export class ApplicationModule {}
4 changes: 2 additions & 2 deletions examples/12-graphql-apollo/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { GraphQLModule, GraphQLFactory } from '@nestjs/graphql';
import { CatsModule } from './cats/cats.module';

@Module({
modules: [CatsModule, GraphQLModule],
imports: [CatsModule, GraphQLModule],
})
export class ApplicationModule {
export class ApplicationModule implements NestModule {
constructor(private readonly graphQLFactory: GraphQLFactory) {}

configure(consumer: MiddlewaresConsumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class CatsResolvers {
}

@DelegateProperty('human')
findHumansById(cat: Cat) {
findHumansById() {
return (mergeInfo: MergeInfo) => ({
fragment: `fragment CatFragment on Cat { humanId }`,
resolve(parent, args, context, info) {
Expand Down
2 changes: 1 addition & 1 deletion examples/13-mongo-typeorm/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { PhotoModule } from './photo/photo.module';
import { Photo } from './photo/photo.entity';

@Module({
modules: [TypeOrmModule.forRoot([Photo]), PhotoModule],
imports: [TypeOrmModule.forRoot([Photo]), PhotoModule],
})
export class ApplicationModule {}
2 changes: 1 addition & 1 deletion examples/14-mongoose-module/src/modules/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CatsModule } from './cats/cats.module';
import { CatSchema } from './cats/schemas/cat.schema';

@Module({
modules: [
imports: [
MongooseModule.forRoot('mongodb://localhost/nest', [
{ name: 'Cat', schema: CatSchema },
]),
Expand Down
1 change: 1 addition & 0 deletions src/common/interfaces/modules/module-metadata.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Controller } from '../controllers/controller.interface';

export interface ModuleMetadata {
modules?: NestModule[] | any[];
imports?: NestModule[] | any[];
components?: any[];
controllers?: Controller[] | any[];
exports?: any[];
Expand Down
4 changes: 4 additions & 0 deletions src/core/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export class DependenciesScanner {
token,
metadata.MODULES as 'modules',
),
...this.container.getDynamicMetadataByToken(
token,
metadata.IMPORTS as 'imports',
),
];
modules.map(related => this.storeRelatedModule(related, token));
}
Expand Down

0 comments on commit 13ddd03

Please sign in to comment.