@nestjs/typeorm#TypeOrmModule TypeScript Examples

The following examples show how to use @nestjs/typeorm#TypeOrmModule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.module.ts    From nest_transact with MIT License 7 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRoot(Config.typeOrmConfig),
    TypeOrmModule.forFeature([
      User,
      Purse,
    ]),
  ],
  controllers: [
    AppController,
  ],
  providers: [
    AppService,
    PurseSavingService,
  ],
})
export class AppModule {
}
Example #2
Source File: card.module.ts    From 42_checkIn with GNU General Public License v3.0 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forFeature([CardRepository]),
    AuthModule,
    forwardRef(() => UserModule),
    LoggerModule,
  ],
  controllers: [CardController],
  providers: [CardService],
  exports: [CardService, TypeOrmModule],
})
export class CardModule {}
Example #3
Source File: mysql.module.ts    From nestjs-api-example with MIT License 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      useClass: TypeOrmConfigService,
      inject: [ConfigService],
    }),
  ],
})
export class MySQLModule {}
Example #4
Source File: app.module.ts    From NestJs-youtube with MIT License 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: 'localhost',
      username: 'myuser',
      password: 'password',
      database: 'nestjs',
      entities: [
        UserEntity,
        PostEntity,
        CommentEntity,
        LikeEntity,
        UserFollower,
        FileEntity,
      ],
      subscribers: [CommentSubscriber],
      synchronize: true,
    }),
    UserModule,
    PostsModule,
    CommentsModule,
    LikesModule,
    UserFollowerModule,
    FilesModule,
    AuthModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }
Example #5
Source File: app.module.ts    From nest-js-boilerplate with MIT License 6 votes vote down vote up
@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
    }),
    TypeOrmModule.forRootAsync({
      useFactory: (cfg: ConfigService) => ({
        type: 'mysql',
        host: cfg.get('MYSQL_HOST') || 'mysql',
        port: (cfg.get('MYSQL_PORT') as unknown) as number,
        database: cfg.get('MYSQL_DB'),
        username: cfg.get('MYSQL_ROOT_USER'),
        password: cfg.get('MYSQL_PASSWORD'),
        entities: ['dist/**/*.entity{.ts,.js}'],
        synchronize: true,
      }),
      inject: [ConfigService],
    }),
    RedisModule.forRootAsync({
      useFactory: (cfg: ConfigService) => ({
        config: {
          url: cfg.get('REDIS_URL'),
        },
      }),
      inject: [ConfigService],
    }),
    V1Module,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export default class AppModule { }
Example #6
Source File: app.module.ts    From barista with Apache License 2.0 6 votes vote down vote up
@Module({
  imports: [TypeOrmModule.forRoot(), ControllersModule, AppQueueModule, ServicesModule,    
    BullModule.forRoot({
      redis: {
      enableReadyCheck: true,
      host: process.env.REDIS_HOST || 'localhost',
      port: Number(process.env.REDIS_PORT) || 6379,
      },
    }),],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
Example #7
Source File: app.module.ts    From The-TypeScript-Workshop with MIT License 6 votes vote down vote up
@Module({
  imports: [
    PledgeModule,
    TypeOrmModule.forRoot({
      type: 'sqlite',
      database: 'db',
      entities: [Pledge],
      synchronize: true,
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
Example #8
Source File: app.module.ts    From domain-driven-hexagon with MIT License 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRoot(typeormConfig),
    // only if you are using GraphQL
    GraphQLModule.forRoot({
      autoSchemaFile: join(process.cwd(), 'src/infrastructure/schema.gql'),
    }),
    UnitOfWorkModule,
    NestEventModule,
    ConsoleModule,
    UserModule,
    WalletModule,
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}
Example #9
Source File: app.module.ts    From svvs with MIT License 6 votes vote down vote up
/**
 * Root module backend-api app
 */
@Module({
  imports: [
    TypeOrmModule.forRoot({
      ...environment.connection,
      entities: [UserEntity],
    }),
    GraphQLModule.forRoot({
      typePaths: ['./**/*.graphql'],
      context: ({req}) => ({req}),
      playground: true,
      resolvers: [resolverMap],
    }),
    UsersModule,
    AuthModule,
  ],
  controllers: [AppController],
})
export class AppModule {
}
Example #10
Source File: app.module.ts    From nest-js-quiz-manager with MIT License 6 votes vote down vote up
@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    TypeOrmModule.forRootAsync(typeOrmAsyncConfig),
    EventEmitterModule.forRoot(),
    MulterModule.register({ dest: './uploads' }),
    QuizModule,
    UserModule,
    AuthModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(ApiTokenCheckMiddleware)
      .forRoutes({ path: '/', method: RequestMethod.ALL });
  }
}
Example #11
Source File: app.module.ts    From aqualink-app with MIT License 6 votes vote down vote up
@Module({
  imports: [
    SiteApplicationsModule,
    SitesModule,
    SiteSurveyPointsModule,
    RegionsModule,
    SurveysModule,
    TypeOrmModule.forRoot(configService.getTypeOrmConfig()),
    UsersModule,
    AuthModule,
    GoogleCloudModule,
    ScheduleModule.forRoot(),
    TasksModule,
    HealthCheckModule,
    TimeSeriesModule,
    CollectionsModule,
    SensorsModule,
    AuditModule,
    DataUploadsModule,
    WindWaveModule,
  ],
  controllers: [AppController],
})
export class AppModule {}
Example #12
Source File: app.module.ts    From gear-js with GNU General Public License v3.0 6 votes vote down vote up
@Module({
  imports: [
    ConfigModule.forRoot({
      load: [configurations],
    }),
    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        type: 'postgres',
        host: configService.get('database.host'),
        port: configService.get('database.port'),
        username: configService.get('database.user'),
        password: configService.get('database.password'),
        database: configService.get('database.name'),
        autoLoadEntities: true,
        synchronize: true,
        entities: ['dist/**/*.entity.js'],
      }),
      inject: [ConfigService],
    }),
    ConsumerModule,
    ProgramsModule,
    MessagesModule,
    MetadataModule,
    HealthcheckModule,
  ],
  controllers: [HealthcheckController],
})
export class AppModule {}
Example #13
Source File: app.module.ts    From life-helper-backend with MIT License 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRoot(TypeOrmConfig),
    RedisModule.register(RedisConfig),
    ScheduleModule.forRoot(),
    SharedModule,
    AuthModule,
    UserModule,
    CalendarModule,
    IpModule,
    DiaryModule,
    UploadModule,
    SystemModule,
    WeatherModule,
  ],

  providers: [{ provide: APP_FILTER, useClass: AllExceptionFilter }],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer): MiddlewareConsumer | void {
    /** 中间件列表 */
    const middlewares = [AuthMiddleware]

    consumer.apply(...middlewares).forRoutes({ path: '*', method: RequestMethod.ALL })
  }
}
Example #14
Source File: article.module.ts    From nestjs-starter-rest-api with MIT License 6 votes vote down vote up
@Module({
  imports: [
    SharedModule,
    TypeOrmModule.forFeature([ArticleRepository]),
    UserModule,
  ],
  providers: [ArticleService, JwtAuthStrategy, ArticleAclService],
  controllers: [ArticleController],
  exports: [ArticleService],
})
export class ArticleModule {}
Example #15
Source File: app.module.ts    From postgres-nest-react-typescript-boilerplate with GNU General Public License v3.0 6 votes vote down vote up
@Module({
  imports: [TypeOrmModule.forRoot(), TodoModule, UserModule],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: APP_FILTER,
      useClass: HttpErrorFilter,
    },
    {
      provide: APP_PIPE,
      useClass: ValidationPipe,
    },
  ],
})
export class AppModule {}
Example #16
Source File: index.ts    From bank-server with MIT License 6 votes vote down vote up
@Module({
  imports: [
    MessageModule,
    LanguageModule,
    forwardRef(() => TransactionModule),
    forwardRef(() => UserModule),
    forwardRef(() => CurrencyModule),
    TypeOrmModule.forFeature([
      BillRepository,
      CurrencyRepository,
      TransactionRepository,
    ]),
  ],
  controllers: [BillController],
  exports: [BillService],
  providers: [BillService, BillSubscriber],
})
export class BillModule {}
Example #17
Source File: audit-log.module.ts    From radiopanel with GNU General Public License v3.0 6 votes vote down vote up
@Module({
	imports: [
		TypeOrmModule.forFeature([AuditLog]),
		SharedModule
	],
	controllers: [AuditLogController],
	providers: [],
})
export class AuditLogModule {}
Example #18
Source File: database.module.ts    From nestjs-starter with MIT License 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRootAsync({
      useFactory: (configService: ConfigService) => configService.get<TypeOrmModuleOptions>(CONFIG_DB_CONFIG),
      inject: [ConfigService],
    }),
  ],
})
export class DatabaseModule {}
Example #19
Source File: app.module.ts    From office-hours with GNU General Public License v3.0 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRoot(typeormConfig),
    ScheduleModule.forRoot(),
    LoginModule,
    ProfileModule,
    CourseModule,
    QueueModule,
    NotificationModule,
    QuestionModule,
    SeedModule,
    ResourcesModule,
    ConfigModule.forRoot({
      envFilePath: [
        '.env',
        ...(process.env.NODE_ENV !== 'production' ? ['.env.development'] : []),
      ],
      isGlobal: true,
    }),
    AdminModule,
    CommandModule,
    SSEModule,
    BackfillModule,
    ReleaseNotesModule,
    InsightsModule,
    // Only use 'pub' for publishing events, 'sub' for subscribing, and 'db' for writing to key/value store
    RedisModule.register([{ name: 'pub' }, { name: 'sub' }, { name: 'db' }]),
    HealthcheckModule,
    AlertsModule,
    SemesterModule,
  ],
})
export class AppModule {}
Example #20
Source File: oauth2-async-use-factory.module.ts    From nestjs-oauth2-server-module with MIT License 6 votes vote down vote up
@Module({
    imports: [
        TypeOrmModule.forRoot({
            type: 'postgres',
            host: 'localhost',
            port: 5432,
            username: 'postgres',
            password: 'postgres',
            database: 'oauth2-server',
            entities: [process.cwd() + '/lib/**/*.entity{.ts,.js}'],
            dropSchema: true,
            synchronize: true
        }),
        Oauth2Module.forRootAsync({
            imports: [UserModule],
            useFactory: (userValidator, userLoader) => ({
                userValidator,
                userLoader,
            }),
            inject: [UserValidator, UserLoader],
        }),
    ],
    providers: [
        FixturesLoaderService,
    ],
    controllers: [
        TestSecuredController,
    ]
})
export class Oauth2AsyncUseFactoryModule {}
Example #21
Source File: app.module.ts    From pknote-backend with GNU General Public License v3.0 6 votes vote down vote up
@Module({
  imports: [
    TypeOrmModule.forRoot(typeOrmConfig),
    RedisModule.forRoot(redisConfig),
    AuthModule,
    ContentModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
Example #22
Source File: app.module.ts    From 42_checkIn with GNU General Public License v3.0 5 votes vote down vote up
@Module({
  imports: [
    ConfigModule.forRoot({
      load: [configuration],
      isGlobal: true,
    }),
    TypeOrmModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        type: 'mysql',
        host: configService.get('database.host'),
        port: configService.get('database.port'),
        username: configService.get('database.username'),
        password: configService.get('database.password'),
        database: configService.get('database.name'),
        entities: [join(__dirname, '/**/*.entity.js')],
        synchronize: true,
      }),
    }),
    // ServeStaticModule.forRoot({
    //   rootPath: resolve(__dirname, '../../../client/build'),
    // }),
    TerminusModule,
    UserModule,
    AuthModule,
    CardModule,
    LogModule,
    HealthModule,
    LoggerModule,
    ThrottlerModule.forRoot({
      ttl: 60,
      limit: 20,
    }),
    WaitingModule,
    HttpModule,
    // MailerModule.forRootAsync({
    //   imports: [ConfigModule],
    //   inject: [ConfigService],
    //   useFactory: (configService: ConfigService) => ({
    //     transport: configService.get('mailer.mail'),
    //     defaults: {
    //       from: '"42 출입 시스템" <[email protected]>',
    //     },
    //     template: {
    //       dir: __dirname + '/templates',
    //       adapter: new EjsAdapter(),
    //       options: {
    //         strict: true,
    //       },
    //     },
    //   }),
    // }),
    ScheduleModule.forRoot(),
  ],
  controllers: [AppController, HealthController, WaitingController],
  providers: [
    AppService,
    Logger,
    { provide: APP_GUARD, useClass: TokenThrottlerGuard },
  ],
})
export class AppModule {}
Example #23
Source File: user.module.ts    From nestjs-api-example with MIT License 5 votes vote down vote up
@Module({
  imports: [TypeOrmModule.forFeature([UserRepository])],
  controllers: [UserController],
  providers: [UserService],
})
export class UserModule {}
Example #24
Source File: files.module.ts    From NestJs-youtube with MIT License 5 votes vote down vote up
@Module({
  imports: [TypeOrmModule.forFeature([FileEntity])],
  controllers: [FilesController],
  providers: [FilesService, GenericService],
})
export class FilesModule {}
Example #25
Source File: users.module.ts    From nest-js-boilerplate with MIT License 5 votes vote down vote up
@Module({
  imports: [TypeOrmModule.forFeature([UserEntity])],
  controllers: [UsersController],
  providers: [UsersService, UsersRepository],
  exports: [UsersService, UsersRepository],
})
export default class UsersModule {}
Example #26
Source File: pledge.module.ts    From The-TypeScript-Workshop with MIT License 5 votes vote down vote up
@Module({
  controllers: [PledgeController],
  imports: [TypeOrmModule.forFeature([Pledge])],
  providers: [PledgeService],
})
export class PledgeModule {}
Example #27
Source File: wallet.module.ts    From domain-driven-hexagon with MIT License 5 votes vote down vote up
@Module({
  imports: [TypeOrmModule.forFeature([WalletOrmEntity])],
  controllers: [],
  providers: [WalletRepository, createWalletWhenUserIsCreatedProvider],
})
export class WalletModule {}
Example #28
Source File: auth.module.ts    From aqualink-app with MIT License 5 votes vote down vote up
@Module({
  imports: [PassportModule, TypeOrmModule.forFeature([User])],
  providers: [FirebaseAuthStrategy],
})
export class AuthModule {}
Example #29
Source File: module.ts    From test with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
feature = TypeOrmModule.forFeature([User])