add typorm with postgres
This commit is contained in:
parent
edec8c0cf9
commit
bcbfd8eac5
14
environment/dev/docker-compose.yaml
Normal file
14
environment/dev/docker-compose.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18
|
||||
ports:
|
||||
- "4301:5432"
|
||||
environment:
|
||||
POSTGRES_DB: dvbooking
|
||||
POSTGRES_PASSWORD: test
|
||||
|
||||
adminer:
|
||||
image: adminer
|
||||
ports:
|
||||
- 4302:8080
|
||||
771
package-lock.json
generated
771
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,10 +21,14 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/config": "^4.0.2",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/typeorm": "^11.0.0",
|
||||
"pg": "^8.16.3",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1"
|
||||
"rxjs": "^7.8.1",
|
||||
"typeorm": "^0.3.27"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
|
||||
@ -1,10 +1,35 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
|
||||
|
||||
const moduleTypeOrm = TypeOrmModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => {
|
||||
return {
|
||||
type: 'postgres',
|
||||
host: configService.get<string>('DATABASE_HOST'),
|
||||
port: parseInt(configService.get<string>('DATABASE_PORT') as string,10),
|
||||
username: configService.get<string>('DATABASE_USER'),
|
||||
password: configService.get<string>('DATABASE_PASS'),
|
||||
database: configService.get<string>('DATABASE_NAME'),
|
||||
entities: [],
|
||||
// synchronize: true,
|
||||
};
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
moduleTypeOrm
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule {
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user