nestjs-playground/src/app.module.ts

31 lines
840 B
TypeScript
Raw Normal View History

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