nestjs-playground/src/app.module.ts

34 lines
976 B
TypeScript

import { Module } from '@nestjs/common';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm'; // DEBUG: Is this necessary? Docs unclear.
import { DevtoolsModule } from '@nestjs/devtools-integration';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Cat } from './cats/cats.entity';
import { CatsModule } from './cats/cats.module';
let dbConfig: TypeOrmModuleOptions;
if ( process.env.NODE_ENV === 'production' ) {
dbConfig = {
type: 'sqlite',
database: 'database/database_development.sqlite3',
entities: [Cat],
}
} else {
dbConfig = {
type: 'sqlite',
database: 'database/database_development.sqlite3',
entities: [Cat],
}
}
@Module({
imports: [
TypeOrmModule.forRoot(dbConfig),
DevtoolsModule.register({ http: process.env.NODE_ENV !== 'production' }),
CatsModule
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}