Implement backend API and database services in Docker setup
- Added a new `api` service for the NestJS backend, including health checks and dependencies on PostgreSQL, Redis, and MinIO. - Introduced PostgreSQL and Redis services with health checks and configurations for data persistence. - Added MinIO for S3-compatible object storage and a one-shot service to initialize required buckets. - Updated the Nginx configuration to proxy requests to the new backend API and MinIO storage. - Enhanced the Dockerfile to support the new API environment variables and configurations. - Updated the `package.json` and `package-lock.json` to include new dependencies for QR code generation and other utilities. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
51
backend/src/database/database.module.ts
Normal file
51
backend/src/database/database.module.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
|
||||
import { Unique } from './validators/unique.validator';
|
||||
|
||||
/**
|
||||
* Database module.
|
||||
* Removed the second PostHog database connection.
|
||||
* Only the main application database is configured.
|
||||
*/
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
type: 'postgres',
|
||||
host: configService.get('DATABASE_HOST'),
|
||||
port: configService.get<number>('DATABASE_PORT'),
|
||||
username: configService.get('DATABASE_USER'),
|
||||
password: configService.get('DATABASE_PASSWORD'),
|
||||
database: configService.get('DATABASE_NAME'),
|
||||
namingStrategy: new SnakeNamingStrategy(),
|
||||
entities: ['dist/**/*.entity.{ts,js}'],
|
||||
migrations: ['dist/database/migrations/*.{ts,js}'],
|
||||
migrationsTableName: 'typeorm_migrations',
|
||||
autoLoadEntities: true,
|
||||
// In production: false. In development: true for auto-schema sync.
|
||||
synchronize: configService.get('ENVIRONMENT') === 'development',
|
||||
connectTimeoutMS: 10_000,
|
||||
maxQueryExecutionTime: 30_000,
|
||||
poolSize: 50,
|
||||
extra: {
|
||||
poolSize: 50,
|
||||
connectionTimeoutMillis: 5000,
|
||||
query_timeout: 30_000,
|
||||
statement_timeout: 30_000,
|
||||
},
|
||||
// No SSL for local/Docker environments
|
||||
ssl:
|
||||
configService.get('ENVIRONMENT') === 'local' ||
|
||||
configService.get('ENVIRONMENT') === 'development'
|
||||
? false
|
||||
: { rejectUnauthorized: false },
|
||||
}),
|
||||
}),
|
||||
],
|
||||
providers: [Unique],
|
||||
})
|
||||
export class DatabaseModule {}
|
||||
Reference in New Issue
Block a user