Add configuration, database, and queue modules for application setup
This commit is contained in:
parent
a99d78c4df
commit
48c9a6a016
23
src/config/configuration.ts
Normal file
23
src/config/configuration.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { env } from 'node:process';
|
||||
|
||||
export default () => ({
|
||||
port: env.PORT || 9999,
|
||||
database: {
|
||||
host: env.DATABASE_HOST || 'localhost',
|
||||
port: env.DATABASE_PORT || 5432,
|
||||
username: env.DATABASE_USERNAME || 'postgres',
|
||||
password: env.DATABASE_PASSWORD || 'password',
|
||||
database: env.DATABASE_NAME || 'payment_system',
|
||||
},
|
||||
redis: {
|
||||
host: env.REDIS_HOST || 'localhost',
|
||||
port: env.REDIS_PORT || 6379,
|
||||
},
|
||||
paymentProcessors: {
|
||||
defaultUrl:
|
||||
env.PAYMENT_PROCESSOR_URL_DEFAULT || 'http://192.168.1.126:8001',
|
||||
fallbackUrl:
|
||||
env.PAYMENT_PROCESSOR_URL_FALLBACK || 'http://192.168.1.126:8002',
|
||||
healthCheckInterval: env.HEALTH_CHECK_INTERVAL || 5000, // 5 segundos
|
||||
},
|
||||
});
|
||||
27
src/modules/database/database.module.ts
Normal file
27
src/modules/database/database.module.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { Payment } from '../payments/entities/payment.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
type: 'postgres',
|
||||
host: configService.get('database.host'),
|
||||
port: configService.get('database.port'),
|
||||
username: configService.get('database.username'),
|
||||
password: configService.get('database.password'),
|
||||
database: configService.get('database.database'),
|
||||
entities: [Payment],
|
||||
synchronize: process.env.NODE_ENV !== 'production', // Apenas para desenvolvimento
|
||||
logging: process.env.NODE_ENV === 'development',
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
TypeOrmModule.forFeature([Payment]),
|
||||
],
|
||||
exports: [TypeOrmModule],
|
||||
})
|
||||
export class DatabaseModule {}
|
||||
19
src/modules/queue/queue.module.ts
Normal file
19
src/modules/queue/queue.module.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { BullModule } from '@nestjs/bullmq';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
BullModule.forRoot({
|
||||
connection: {
|
||||
host: '192.168.1.112',
|
||||
port: 6379,
|
||||
username: 'default',
|
||||
password: '7TfhqvHPe98AQq123',
|
||||
},
|
||||
}),
|
||||
],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
exports: [],
|
||||
})
|
||||
export class QueueModule {}
|
||||
Loading…
x
Reference in New Issue
Block a user