How to use the @nestjs/mongoose.MongooseModule.forFeature function in @nestjs/mongoose

To help you get started, we’ve selected a few @nestjs/mongoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marcomelilli / nestjs-email-authentication / src / auth / auth.module.ts View on Github external
Module, MiddlewareConsumer, NestModule
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { JwtStrategy } from './passport/jwt.strategy';
import { AuthController } from './auth.controller';
import { UserSchema } from '../users/schemas/user.schema';
import { EmailVerificationSchema } from '../auth/schemas/emailverification.schema';
import { ForgottenPasswordSchema } from './schemas/forgottenpassword.schema';
import { ConsentRegistrySchema } from './schemas/consentregistry.schema';
import { UsersService } from '../users/users.service';
import { JWTService } from './jwt.service';
import { MongooseModule } from '@nestjs/mongoose';
import { LoggerMiddleware } from '../common/middlewares/logger.middleware';

@Module({
  imports: [MongooseModule.forFeature([
    { name: 'User', schema: UserSchema },
    { name: 'EmailVerification', schema: EmailVerificationSchema },
    { name: 'ForgottenPassword', schema: ForgottenPasswordSchema },
    { name: 'ConsentRegistry', schema: ConsentRegistrySchema }
  ])],
  controllers: [AuthController],
  providers: [AuthService, UsersService, JWTService, JwtStrategy],
})
export class AuthModule implements NestModule {
  public configure(consumer: MiddlewareConsumer) {
     consumer
      .apply(LoggerMiddleware)
      // .exclude(
      //   { path: 'example', method: RequestMethod.GET },
      // )
      .forRoutes(AuthController);
github Kibibit / achievibit / src / modules / repos / repos.module.ts View on Github external
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';

import { REPO_MODEL_NAME, RepoSchema } from '@kb-models';

import { ReposController } from './repos.controller';
import { ReposService } from './repos.service';


@Module({
  imports: [ MongooseModule.forFeature([ { name: REPO_MODEL_NAME, schema: RepoSchema } ]) ],
  providers: [ ReposService ],
  controllers: [ ReposController ],
  exports: [ ReposService ]
})
export class ReposModule { }
github denlysenko / bookapp-api / src / users / user.module.ts View on Github external
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { FilesModule } from 'files/files.module';

import { UserSchema } from './schemas/user.schema';
import { UserResolver } from './user.resolvers';
import { UserService } from './user.service';

@Module({
  imports: [
    MongooseModule.forFeature([{ name: 'User', schema: UserSchema }]),
    FilesModule,
  ],
  providers: [UserService, UserResolver],
  exports: [UserService],
})
export class UsersModule {}
github jkchao / blog-service / src / module / heros / heros.module.ts View on Github external
import { Module } from '@nestjs/common';
import { HerosService } from './heros.service';
import { HerosResolver } from './heros.resolvers';
import { MongooseModule } from '@nestjs/mongoose';
import { HerosSchema } from './schema/heros.schema';
import { EmailModule } from '../common/email/email.module';

@Module({
  imports: [MongooseModule.forFeature([{ name: 'Heros', schema: HerosSchema }]), EmailModule],
  providers: [HerosService, HerosResolver]
})
export class HerosModule {}
github nartc / nest-mean / server / src / user / user.module.ts View on Github external
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { User } from './models/user.model';
import { UserController } from './user.controller';
import { UserService } from './user.service';

@Module({
    imports: [MongooseModule.forFeature([{ name: User.modelName, schema: User.model.schema }])],
    providers: [UserService],
    controllers: [UserController],
    exports: [UserService],
})
export class UserModule {
}
github vellengs / nestx / packages / server / src / cms / cms.module.ts View on Github external
{ name: 'Page', schema: PageSchema },
  { name: 'Photo', schema: PhotoSchema },
  { name: 'Widget', schema: WidgetSchema },
  { name: 'Content', schema: ContentSchema },
  { name: 'Custom', schema: CustomSchema },
];
@Module({
  imports: [
    MulterModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) => ({
        dest: configService.get('MULTER_DEST'),
      }),
      inject: [ConfigService],
    }),
    MongooseModule.forFeature(models),
  ],
  controllers: [...CmsControllers],
  providers: [...CmsServices],
})
export class CmsModule {}
github dzzzzzy / Nestjs-Learning / demo / todo / src / feature / users / users.module.ts View on Github external
import { Module, forwardRef } from '@nestjs/common';
import { UsersService } from './users.service';
import { MongooseModule } from '@nestjs/mongoose';
import { UserSchema, TodoSchema } from './schemas/user.schema';
import { UsersController } from './users.controller';
import { PasswordModule } from '../../common/password/password.module';
import { AuthModule } from '../auth/auth.module';

@Module({
  imports: [
    MongooseModule.forFeature([
      { name: 'User', schema: UserSchema },
      { name: 'Todo', schema: TodoSchema },
    ]),
    forwardRef(() => AuthModule),
    PasswordModule,
  ],
  providers: [UsersService],
  exports: [UsersService],
  controllers: [UsersController],
})
export class UsersModule { }
github djjorik / angular-chat / server / cats / cats.module.ts View on Github external
import { UserSchema } from './schemas/user.schema';
import { Module, NestModule, MiddlewaresConsumer, RequestMethod  } from '@nestjs/common';
import { CatsController } from './cats.controller';
import { CatsService } from './cats.service';
import { MongooseModule } from '@nestjs/mongoose';
import { RoomSchema } from '../cats/schemas/room.schema';
import { EventsGateway } from '../events.gateway';
import { CorsMiddleware } from './cors.middleware';

@Module({
  imports: [MongooseModule.forFeature([{ name: 'Room', schema: RoomSchema }, { name: 'User', schema: UserSchema }])],
  controllers: [CatsController],
  components: [CatsService, EventsGateway],
  exports: [CatsService]
})

export class CatsModule {
   configure(consumer: MiddlewaresConsumer): void {
        consumer.apply(CorsMiddleware).forRoutes(
            { path: '*', method: RequestMethod.ALL},
        );
    }
}
github jkchao / blog-service / src / module / link / link.module.ts View on Github external
import { Module } from '@nestjs/common';
import { LinkService } from './link.service';
import { LinkResolver } from './link.resolvers';
import { MongooseModule } from '@nestjs/mongoose';
import { LinkSchema } from './schema/link.schema';

@Module({
  imports: [MongooseModule.forFeature([{ name: 'Links', schema: LinkSchema }])],
  providers: [LinkService, LinkResolver]
})
export class LinkModule {}
github nestjs / nest / sample / 06-mongoose / src / cats / cats.module.ts View on Github external
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { CatsController } from './cats.controller';
import { CatsService } from './cats.service';
import { CatSchema } from './schemas/cat.schema';

@Module({
  imports: [MongooseModule.forFeature([{ name: 'Cat', schema: CatSchema }])],
  controllers: [CatsController],
  providers: [CatsService],
})
export class CatsModule {}