Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}),
// Database
// https://docs.nestjs.com/techniques/database
TypeOrmModule.forRootAsync({
useFactory: async (config: ConfigService) => ({
entities: [`${__dirname}/entity/**/*.{js,ts}`],
subscribers: [`${__dirname}/subscriber/**/*.{js,ts}`],
migrations: [`${__dirname}/migration/**/*.{js,ts}`],
...config.get('db')
}),
inject: [ConfigService]
}),
// Static Folder
// https://docs.nestjs.com/recipes/serve-static
// https://docs.nestjs.com/techniques/mvc
ServeStaticModule.forRoot({
rootPath: `${__dirname}/../public`,
renderPath: '/'
}),
// Module Router
// https://github.com/nestjsx/nest-router
RouterModule.forRoutes([{
path: 'aws',
module: AWSModule
}, {
path: 'test',
module: SampleModule
}]),
// Service Modules
CommonModule, // Global
BaseModule,
AWSModule,
autoSchemaFile: '../schema.graphql',
// GraphQL Subscriptions authentication https://github.com/nestjs/docs.nestjs.com/issues/394
context: ({ req, connection }) => (connection ? { req: { headers: connection.context } } : { req }),
installSubscriptionHandlers: true,
debug: DEBUG,
}),
TypeOrmModule.forFeature([Message, User, Channel, Member, Invitation, Media]),
JwtModule.register({
secret: JWT_SECRET,
signOptions: { expiresIn: JWT_EXPIRES_IN },
}),
];
if (DEBUG) {
const rootPath = join(__dirname, '../../web/dist');
imports.unshift(ServeStaticModule.forRoot({ rootPath }));
}
@Module({
imports,
controllers: [MediaController],
providers: [
DateScalar,
RedisService,
UserService,
MediaService,
MessageService,
MediaResolver,
ChannelResolver,
ChannelService,
MessageResolver,
UserResolver,
import { Module } from '@nestjs/common';
import { join } from 'path';
import { ServeStaticModule } from '@nestjs/serve-static';
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client'),
}),
],
})
export class AppModule {}
import { Module } from '@nestjs/common';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: '',
viewsPath: join(process.cwd(), '<%= getBrowserDistDirectory() %>'),
bundle: require('../server/main'),
liveReload: true
})
]
})
export class ApplicationModule {}