@nestjs/common#Module TypeScript Examples
The following examples show how to use
@nestjs/common#Module.
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 |
@Module({
imports: [
TypeOrmModule.forRoot(Config.typeOrmConfig),
TypeOrmModule.forFeature([
User,
Purse,
]),
],
controllers: [
AppController,
],
providers: [
AppService,
PurseSavingService,
],
})
export class AppModule {
}
Example #2
Source File: auth.module.ts From 42_checkIn with GNU General Public License v3.0 | 6 votes |
@Module({
imports: [
HttpModule,
PassportModule,
JwtModule.registerAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
secret: configService.get('jwt.secret'),
signOptions: { expiresIn: '7d' },
}),
}),
LoggerModule,
],
providers: [AuthService, JwtStrategy, FtStrategy],
exports: [AuthService],
})
export class AuthModule {}
Example #3
Source File: firebase-admin.module.ts From nestjs-firebase-admin with MIT License | 6 votes |
@Module({})
export class FirebaseAdminModule {
static forRoot(options: FirebaseAdminModuleOptions): DynamicModule {
return {
module: FirebaseAdminModule,
imports: [FirebaseAdminCoreModule.forRoot(options)],
};
}
static forRootAsync(options: FirebaseAdminModuleAsyncOptions): DynamicModule {
return {
module: FirebaseAdminModule,
imports: [FirebaseAdminCoreModule.forRootAsync(options)],
};
}
}
Example #4
Source File: gcloud-storage.module.ts From nestjs-gcloud-storage with MIT License | 6 votes |
@Module({})
export class GCloudStorageModule {
static withConfig(options: GCloudStorageOptions): DynamicModule {
return {
module: GCloudStorageModule,
imports: [GCloudStorageCoreModule.withConfig(options)],
};
}
static withConfigAsync(options: GCloudStorageAsyncOptions): DynamicModule {
return {
module: GCloudStorageModule,
imports: [GCloudStorageCoreModule.withConfigAsync(options)],
};
}
}
Example #5
Source File: app.module.ts From Cromwell with MIT License | 6 votes |
@Module({
imports: [
RestApiModule.forRoot(),
AuthModule,
ThrottlerModule.forRoot({
ttl: 30,
limit: 100,
}),
],
})
export class AppModule { }
Example #6
Source File: app.module.ts From nestjs-mercurius with MIT License | 6 votes |
@Module({
imports: [
MercuriusModule.forRoot({
autoSchemaFile: true,
schemaDirectives: {
uppercase: UpperCaseDirective,
},
subscription: true,
}),
],
providers: [CatService, DogService, AnimalResolver, CatResolver],
exports: [CatService],
})
export class AppModule {}
Example #7
Source File: config.module.ts From nestjs-api-example with MIT License | 6 votes |
@Module({
providers: [
{
provide: ConfigService,
useValue: new ConfigService('.env'),
},
],
exports: [ConfigService],
})
export class ConfigModule {}
Example #8
Source File: app.module.ts From typegraphql-nestjs with MIT License | 6 votes |
@Module({
imports: [
TypeGraphQLModule.forRoot({
emitSchemaFile: true,
validate: false,
}),
RecipeModule,
],
})
export default class AppModule {}
Example #9
Source File: app.module.ts From NestJs-youtube with MIT License | 6 votes |
@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 #10
Source File: mailgun.module.ts From nestjs-mailgun with MIT License | 6 votes |
@Module({})
export class MailgunModule {
public static forRoot(config: Options) {
return {
module: MailgunModule,
// controllers: [
// ...controllers,
// ],
providers: [
{ provide: MAILGUN_CONFIGURATION, useValue: config },
MailgunService,
],
exports: [MailgunService],
};
}
public static forAsyncRoot(config: OptionsAsync) {
return {
module: MailgunModule,
// controllers: [
// ...controllers,
// ],
imports: config.imports || [],
providers: [this.createAsyncProviders(config), MailgunService],
exports: [MailgunService],
};
}
private static createAsyncProviders(
options: OptionsAsync,
): Provider {
return {
provide: MAILGUN_CONFIGURATION,
useFactory: options.useFactory,
inject: options.inject || [],
};
}
}
Example #11
Source File: ses.module.ts From nestjs-ses with MIT License | 6 votes |
@Module({})
export class SesModule {
public static forRoot(config: ConfigurationSes) {
return {
module: SesModule,
// controllers: [
// ...controllers,
// ],
providers: [
{ provide: AKI_KEY, useValue: config.AKI_KEY },
{
provide: REGION,
useValue: config.REGION,
},
{ provide: SECRET, useValue: config.SECRET },
SesService,
],
exports: [SesService],
};
}
}
Example #12
Source File: app.module.ts From nest-js-boilerplate with MIT License | 6 votes |
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
}),
MongooseModule.forRoot(process.env.MONGODB_URL as string, {
useCreateIndex: true,
// flag to allow users to fall back to the old
// parser if they find a bug in the new parse
useNewUrlParser: true,
useUnifiedTopology: true,
}),
RedisModule.forRootAsync({
useFactory: (cfg: ConfigService) => ({
config: {
url: cfg.get('REDIS_URL'),
},
}),
inject: [ConfigService],
}),
V1Module,
],
controllers: [AppController],
providers: [AppService],
})
export default class AppModule { }
Example #13
Source File: app.module.ts From barista with Apache License 2.0 | 6 votes |
@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 #14
Source File: app.module.ts From The-TypeScript-Workshop with MIT License | 6 votes |
@Module({
imports: [
PledgeModule,
TypeOrmModule.forRoot({
type: 'sqlite',
database: 'db',
entities: [Pledge],
synchronize: true,
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Example #15
Source File: event-store-heroes.module.ts From nestjs-geteventstore with MIT License | 6 votes |
@Module({
controllers: [HealthController, HeroesGameController],
providers: [
HeroRepository,
...CommandHandlers,
...EventHandlers,
...QueryHandlers,
HeroesGameSagas,
],
imports: [
ContextModule.register(),
TerminusModule,
LoggerModule.forRoot(),
CqrsEventStoreModule.register(
eventStoreConnectionConfig,
eventStoreSubsystems,
eventBusConfig,
),
],
})
export class EventStoreHeroesModule {}
Example #16
Source File: app.module.ts From domain-driven-hexagon with MIT License | 6 votes |
@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 #17
Source File: app.module.ts From whispr with MIT License | 6 votes |
@Module({
imports: [
TerminusModule,
GraphQLModule.forRootAsync<ApolloDriverConfig>({
imports: [ConfigModule],
driver: ApolloDriver,
useFactory: async (configService: ConfigService) => ({
autoSchemaFile: configService.get('AUTO_SCHEMA_FILE'),
introspection: configService.get('INTROSPECTION'),
playground: false,
cors: false,
plugins: configService.get('PLAYGROUND') ? [ApolloServerPluginLandingPageLocalDefault()] : [],
installSubscriptionHandlers: true,
}),
inject: [ConfigService],
}),
MongooseModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => configService.getMongooseOptions(),
inject: [ConfigService],
}),
PubSubModule,
WhispModule,
TagGroupModule,
TagModule,
SequenceModule,
ConfigModule,
AWSCredsModule,
FileModule,
DistributionModule,
EventModule,
WebhookModule,
AuthModule,
],
providers: [AppService],
controllers: [AppController, HealthController],
})
export class AppModule {}
Example #18
Source File: app.module.ts From adminjs-nestjs with MIT License | 6 votes |
@Module({
imports: [
MongooseModule.forRoot('mongodb://localhost:27017/nest'),
AdminModule.createAdminAsync({
imports: [
MongooseSchemasModule,
],
inject: [
getModelToken('Admin'),
],
useFactory: (adminModel: Model<Admin>) => ({
adminJsOptions: {
rootPath: '/admin',
resources: [
{ resource: adminModel },
],
},
auth: {
authenticate: async (email, password) => Promise.resolve({ email: 'test' }),
cookieName: 'test',
cookiePassword: 'testPass',
},
}),
customLoader: ExpressCustomLoader,
}),
MongooseSchemasModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule { }
Example #19
Source File: account.module.ts From uniauth-backend with MIT License | 6 votes |
@Module({
imports: [
JwtModule.register({
secret: accessTokenJwtConstants.secret,
signOptions: { expiresIn: accessTokenJwtConstants.expiresIn },
}),
ApplicationModule,
UserModule,
AuthModule,
MailerModule,
],
controllers: [AccountController],
providers: [AccountService],
})
export class AccountModule {}
Example #20
Source File: app.module.ts From svvs with MIT License | 6 votes |
/**
* 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 #21
Source File: DesktopAPI.ts From rewind with MIT License | 6 votes |
export async function setupBootstrap({ userDataPath, logDirectory }: SetupBootstrapSettings) {
const rewindCfgPath = getRewindCfgPath(userDataPath);
const rewindCfgProvider = {
provide: REWIND_CFG_PATH,
useValue: rewindCfgPath,
};
@Module({
providers: [rewindCfgProvider, DesktopConfigService],
controllers: [DesktopConfigController, SetupStatusController],
})
class SetupModule {}
const app = await NestFactory.create<NestExpressApplication>(SetupModule, { logger: createLogger(logDirectory) });
app.setGlobalPrefix(globalPrefix);
app.enableCors();
await app.listen(port, listenCallback);
return app;
}
Example #22
Source File: app.module.ts From runebot with MIT License | 6 votes |
@Module({
imports: [
AppConfigModule,
HealthModule,
TwitterModule,
DiscordModule,
EthereumModule,
ScheduleModule.forRoot(),
CacheModule,
],
providers: [AppService],
})
export class AppModule {}
Example #23
Source File: app.module.ts From nest-js-quiz-manager with MIT License | 6 votes |
@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 #24
Source File: containerBuilder.module.ts From amplication with Apache License 2.0 | 6 votes |
@Module({})
export class ContainerBuilderModule {
static forRoot(options: ContainerBuilderModuleOptions): DynamicModule {
return {
module: ContainerBuilderModule,
providers: [
{
provide: CONTAINER_BUILDER_OPTIONS,
useValue: { ...options, providers: {} },
},
ContainerBuilderService,
],
exports: [ContainerBuilderService],
};
}
static forRootAsync(
options: ContainerBuilderModuleAsyncOptions
): DynamicModule {
const { imports, ...rest } = options;
return {
module: ContainerBuilderModule,
providers: [
// @ts-ignore
{
provide: CONTAINER_BUILDER_OPTIONS,
// @ts-ignore
...rest,
},
ContainerBuilderService,
],
exports: [ContainerBuilderService],
imports,
};
}
}