2023-10-15 16:25:55 +00:00
|
|
|
import { Module } from '@nestjs/common';
|
|
|
|
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm'; // DEBUG: Is this necessary? Docs unclear.
|
2023-10-18 22:11:32 +00:00
|
|
|
import { DevtoolsModule } from '@nestjs/devtools-integration';
|
2023-10-15 16:25:55 +00:00
|
|
|
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',
|
2023-10-18 22:11:32 +00:00
|
|
|
database: 'database/database_development.sqlite3',
|
|
|
|
entities: [Cat],
|
2023-10-15 16:25:55 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dbConfig = {
|
|
|
|
type: 'sqlite',
|
|
|
|
database: 'database/database_development.sqlite3',
|
|
|
|
entities: [Cat],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Module({
|
2023-10-18 22:11:32 +00:00
|
|
|
imports: [
|
|
|
|
TypeOrmModule.forRoot(dbConfig),
|
|
|
|
DevtoolsModule.register({ http: process.env.NODE_ENV !== 'production' }),
|
|
|
|
CatsModule
|
|
|
|
],
|
2023-10-15 16:25:55 +00:00
|
|
|
controllers: [AppController],
|
|
|
|
providers: [AppService],
|
|
|
|
})
|
|
|
|
export class AppModule {}
|