mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
feat:mvp1 initial commit
This commit is contained in:
20
typeorm.cli.ts
Normal file
20
typeorm.cli.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './src/app.module';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Getting data source through NestJS app helps in getting entities dynamically with "autoLoadEntities" NestJS feature
|
||||
* as well as keeping migrations config in sync with what is configured in the app.
|
||||
*/
|
||||
async function getTypeOrmDataSource() {
|
||||
process.env.MIGRATIONS_RUN = 'false';
|
||||
|
||||
const app = await NestFactory.createApplicationContext(AppModule);
|
||||
|
||||
const dataSource = app.get(DataSource);
|
||||
await app.close();
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
export default getTypeOrmDataSource();
|
||||
Reference in New Issue
Block a user