Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/src/prisma.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const DB_PWD = encodeURIComponent(process.env.POSTGRES_PASSWORD || "default"); /
const DB_PORT = process.env.POSTGRES_PORT || 5432;
const DB_NAME = process.env.POSTGRES_DATABASE || "postgres";
const DB_SCHEMA = process.env.POSTGRES_SCHEMA || "app";
const DB_POOL_SIZE = parseInt(process.env.POSTGRES_POOL_SIZE || "5", 10);
// SSL settings for PostgreSQL 17+ which requires SSL by default
const SSL_MODE = (process.env.NODE_ENV === 'local' || 'unittest') ? 'prefer' : 'require'; // 'require' for aws deployments, 'prefer' for local development or ut in gha
const dataSourceURL = `postgresql://${DB_USER}:${DB_PWD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?schema=${DB_SCHEMA}&connection_limit=5&sslmode=${SSL_MODE}`;
const dataSourceURL = `postgresql://${DB_USER}:${DB_PWD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?schema=${DB_SCHEMA}&connection_limit=${DB_POOL_SIZE}&sslmode=${SSL_MODE}`;

@Injectable({ scope: Scope.DEFAULT})
class PrismaService extends PrismaClient<Prisma.PrismaClientOptions, 'query'> implements OnModuleInit, OnModuleDestroy {
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/api/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ resource "aws_ecs_task_definition" "node_api_task" {
name = "POSTGRES_SCHEMA"
value = "${var.db_schema}"
},
{
name = "POSTGRES_POOL_SIZE"
value = "${var.postgres_pool_size}"
},
{
name = "PORT"
value = "3000"
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/api/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,9 @@ variable "is_public_api" {
description = "Flag to indicate if the API is public or private"
type = bool
default = true
}
variable "postgres_pool_size" {
description = "The size of the connection pool for the API"
type = string
default = "1"
}
2 changes: 1 addition & 1 deletion infrastructure/database/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ variable "app_env" {
variable "min_capacity" {
description = "Minimum capacity for Aurora Serverless v2"
type = number
default = 0.5
default = 0
}

variable "max_capacity" {
Expand Down
Loading