Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CatModule } from './cat/cat.module';
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'postgres',
url: process.env.DATABASE_URL,
synchronize: true,
entities: [__dirname + '/**/*.entity.{ts,js}'],
}),
GraphQLModule.forRoot({
debug: true,
playground: true,
typePaths: ['./**/*.graphql'],
installSubscriptionHandlers: true,
// context: ({req}) => {
// return {req};
// },
}),
CatModule,
],
})
export class AppModule {}
beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [
MongooseModule.forRoot(config.MONGO_URL),
TagsModule,
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
path: '/api/v2',
context: ({ req, res }: { req: Request; res: Response }) => ({
request: req
})
})
]
})
.overrideProvider(TagsService)
.useValue(tagsService)
.compile();
app = await module.createNestApplication().init();
});
beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [
MongooseModule.forRoot(config.MONGO_URL),
LinksModule,
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
path: '/api/v2'
})
]
})
.overrideProvider(LinksService)
.useValue(linksService)
.compile();
app = await module.createNestApplication().init();
});
import { Module } from '@nestjs/common'
import { GraphQLModule } from '@nestjs/graphql'
import { BookModule } from './book/book.module'
import { AuthModule } from './auth/auth.module'
import { UserModule } from './user/user.module'
@Module({
imports: [
BookModule,
UserModule,
GraphQLModule.forRoot({
autoSchemaFile: 'graphql/schema.gql',
debug: true,
playground: true,
context: ({ req }) => ({ req })
}),
AuthModule
]
})
export class AppModule {}
AuthService,
CryptoService,
MailService
]
const RESOLVERS = [AmendResolver, TextResolver, EventResolver, UserResolver]
const CONTROLLERS = [AppController]
const TASKS = [CheckAmendVoteTask]
const GATEWAYS = [EventGateway, AmendGateway, UserGateway, TextGateway]
const PROVIDERS = [...databaseProvider]
@Module({
controllers: CONTROLLERS,
providers: [...PROVIDERS, ...GATEWAYS, ...SERVICES, ...TASKS, ...RESOLVERS],
imports: [
ScheduleModule.register(),
GraphQLModule.forRoot({
autoSchemaFile: 'schema.gql',
installSubscriptionHandlers: true,
formatError(error) {
return error
}
})
]
})
export class AppModule {}
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
};
if (configService.mongoAuthEnabled) {
options.user = configService.mongoUser;
options.pass = configService.mongoPassword;
}
return options;
},
inject: [ConfigService],
}),
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
installSubscriptionHandlers: true,
context: ({ req }: any) => ({ req }),
definitions: {
path: join(process.cwd(), 'src/graphql.classes.ts'),
outputAs: 'class',
},
}),
UsersModule,
AuthModule,
ConfigModule,
],
})
export class AppModule {}
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserModule } from './user/user.module';
@Module({
imports: [
GraphQLModule.forRoot({
autoSchemaFile: 'schema.gql',
}),
UserModule,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}