Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { RoomsModule } from './rooms/rooms.module';
import { MongooseModule } from '@nestjs/mongoose';
import { CorsMiddleware } from './middlewares/cors.middleware';
import { AuthModule } from './auth/auth.module';
const getMongoUrl = () => {
if (process.env.MONGOUSER && process.env.MONGOPASSWORD) {
return `mongodb://${process.env.MONGOUSER}:${process.env.MONGOPASSWORD}@ds249839.mlab.com:49839/angular-nest-chat-app`;
} else {
return 'mongodb://localhost:27017/nest';
}
};
@Module({
imports: [MongooseModule.forRoot(getMongoUrl()),
UsersModule,
RoomsModule,
AuthModule
],
components: []
})
export class ApplicationModule {
// configure(consumer: MiddlewaresConsumer): void {
// consumer.apply(CorsMiddleware).forRoutes('*');
// }
}
beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [
MongooseModule.forRoot(config.MONGO_URL),
ArticlesModule,
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
path: '/api/v2',
context: ({ req, res }: { req: Request; res: Response }) => ({
request: req
})
})
]
})
.overrideProvider(ArticlesSercice)
.useValue(articleService)
.compile();
app = await module.createNestApplication().init();
});
beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [
MongooseModule.forRoot(config.MONGO_URL),
HerosModule,
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
path: '/api/v2',
context: ({ req, res }: { req: Request; res: Response }) => ({
request: req
})
})
]
})
.overrideProvider(HerosService)
.useValue(heroService)
.overrideProvider(EmailService)
.useValue(emailService)
.compile();
beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [
MongooseModule.forRoot(config.MONGO_URL),
CommentsModule,
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
path: '/api/v2',
context: ({ req, res }: { req: Request; res: Response }) => ({
request: req
})
})
]
})
.overrideProvider(CommentsService)
.useValue(commentsService)
.overrideProvider(ArticlesSercice)
.useValue({
findOneArticle() {
return { _id: '123' };
import { Module, NestModule } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { TodosModule } from './todos/todos.module';
import { UsersModule } from './users/users.module';
import { AuthModule } from './auth/auth.module';
@Module({
imports: [
MongooseModule.forRoot('mongodb://localhost/nest'),
TodosModule,
UsersModule,
AuthModule],
controllers: [],
providers: [],
})
export class AppModule {}
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { MongooseModule } from '@nestjs/mongoose';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CatsModule } from './cats/cats.module';
@Module({
imports: [
CatsModule,
GraphQLModule.forRoot({
autoSchemaFile: 'schema.gql',
}),
MongooseModule.forRoot('mongodb://localhost/nest'),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from './auth';
import { CoreModule } from './core';
import { CommerceModule } from './commerce';
import { CmsModule } from './cms';
import { MONGODB_URI } from './utils';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [
TypeOrmModule.forRoot(),
MongooseModule.forRoot(MONGODB_URI, {
useCreateIndex: true,
useNewUrlParser: true,
}),
AuthModule,
CoreModule,
CmsModule,
CommerceModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
} from '@nestjs/terminus';
const getTerminusOptions = (
mongoose: MongooseHealthIndicator,
): TerminusModuleOptions => ({
endpoints: [
{
url: '/health',
healthIndicators: [async () => await mongoose.pingCheck('mongo')],
},
],
});
@Module({
imports: [
MongooseModule.forRoot('mongodb://localhost:27017/test'),
TerminusModule.forRootAsync({
inject: [MongooseHealthIndicator],
useFactory: getTerminusOptions,
}),
],
})
export class HealthModule {}
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { CatsModule } from './cats/cats.module';
import { CatSchema } from './cats/schemas/cat.schema';
@Module({
modules: [
MongooseModule.forRoot('mongodb://localhost/nest', [
{ name: 'Cat', schema: CatSchema },
]),
CatsModule,
],
})
export class ApplicationModule {}
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { MongooseModule } from '@nestjs/mongoose';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from './auth/auth.module';
import { CoreModule } from './core/core.module';
import { CommerceModule } from './commerce/commerce.module';
import { CmsModule } from './cms/cms.module';
@Module({
imports: [
TypeOrmModule.forRoot(),
MongooseModule.forRoot('mongodb://localhost/nestx-server'),
AuthModule,
CoreModule,
CmsModule,
CommerceModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule { }