From 13c9d59d6e7054cd631ba6d0de95f782ba27a730 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Fri, 26 Dec 2025 00:39:52 +0100 Subject: [PATCH 1/6] REMOVE unused code relating to generating presignedurls --- server/controllers/analysisEntryController.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/server/controllers/analysisEntryController.js b/server/controllers/analysisEntryController.js index 38b955c..3fa70a5 100644 --- a/server/controllers/analysisEntryController.js +++ b/server/controllers/analysisEntryController.js @@ -1,4 +1,4 @@ -import { generateS3GetPresignedUrl, generateS3PutPresignedUrl } from '../integrations/aws/s3.js'; +import { generateS3GetPresignedUrl } from '../integrations/aws/s3.js'; import { createAnalysisEntryInDb, getAnalysisEntryDetailsById, markAnalysisEntryAsSubmitted } from '../models/analysisEntryModel.js'; import { processTranscriptionRequest } from '../services/analysisService.js'; @@ -71,17 +71,3 @@ export const getAnalysisEntryDetails = async (req, res) => { transcriptionSegments: analysisEntryDetails.transcription_segments, }); }; - -export const getAnalysisEntryPresignedUploadUrl = async (req, res) => { - const { analysisEntryId, analysisId } = req.body; - - const key = `analysis/${analysisId}/${analysisEntryId}/recording.mp4`; - - const analysisEntryPresignedUrl = await generateS3PutPresignedUrl(key); - - return res.status(200).json({ - success: true, - message: 'PresignedUploadUrl retrieved successfully', - analysisEntryPresignedUploadUrl: analysisEntryPresignedUrl, - }); -}; From 19a87ca951b3897c279ae96af1858595dc768577 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Fri, 26 Dec 2025 00:46:49 +0100 Subject: [PATCH 2/6] ADD new minio S3 related variables --- .env.example | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 25029d4..d397c4a 100644 --- a/.env.example +++ b/.env.example @@ -23,4 +23,8 @@ AWS_SECRET_ACCESS_KEY= AWS_ACCESS_KEY_ID= AWS_REGION= AWS_BUCKET= -TRANSCRIPTION_ENABLED= \ No newline at end of file + +TRANSCRIPTION_ENABLED= + +MINIO_ROOT_USER= +MINIO_ROOT_PASSWORD= \ No newline at end of file From af1cbc18b1559d2b968b1822dcbaaff58893ab70 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Fri, 26 Dec 2025 09:50:16 +0100 Subject: [PATCH 3/6] UPDATE s3 client config to minIO --- server/integrations/aws/s3.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/integrations/aws/s3.js b/server/integrations/aws/s3.js index 8413349..5b83b20 100644 --- a/server/integrations/aws/s3.js +++ b/server/integrations/aws/s3.js @@ -2,10 +2,12 @@ import { S3Client, GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3 import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; export const s3client = new S3Client({ - region: process.env.AWS_REGION, - credentials: { // https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/modules/credentials.html - accessKeyId: process.env.AWS_ACCESS_KEY_ID, - secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, + region: process.env.AWS_REGION, // irrelevant since miniIO doesnt takei into account + endpoint: 'http://localhost:9000', // Container network endpoint + forcePathStyle: true, // Required for MinIO path-style URLs + credentials: { + accessKeyId: process.env.MINIO_ROOT_USER, + secretAccessKey: process.env.MINIO_ROOT_PASSWORD, }, }); From 876e417000b06a74c2de8c25109204f128b1f5e9 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Fri, 26 Dec 2025 10:35:24 +0100 Subject: [PATCH 4/6] RENAME AWS_REGION env variable to S3_REGION --- .env.example | 2 +- .kilocode/rules/memory-bank/tech.md | 2 +- compose.yaml | 80 ++++++++++++++++++----------- server/integrations/aws/s3.js | 2 +- 4 files changed, 52 insertions(+), 34 deletions(-) diff --git a/.env.example b/.env.example index d397c4a..3b1c228 100644 --- a/.env.example +++ b/.env.example @@ -21,7 +21,7 @@ PORT=3000 AWS_SECRET_ACCESS_KEY= AWS_ACCESS_KEY_ID= -AWS_REGION= +S3_REGION= AWS_BUCKET= TRANSCRIPTION_ENABLED= diff --git a/.kilocode/rules/memory-bank/tech.md b/.kilocode/rules/memory-bank/tech.md index 60bdc49..1c79ee6 100644 --- a/.kilocode/rules/memory-bank/tech.md +++ b/.kilocode/rules/memory-bank/tech.md @@ -89,7 +89,7 @@ PRISMA_POSTGRES_CONNECTION_STRING=postgresql://user:password@localhost:5432/uxca # AWS S3 AWS_ACCESS_KEY_ID=your-access-key AWS_SECRET_ACCESS_KEY=your-secret-key -AWS_REGION=eu-west-3 +S3_REGION=eu-west-3 AWS_BUCKET=your-bucket-name # Stripe diff --git a/compose.yaml b/compose.yaml index a2c8073..45d6de1 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,38 +1,56 @@ name: uxcaptain services: - server: - container_name: server - build: - context: . - dockerfile: Dockerfile.dev - environment: - NODE_ENV: ${NODE_ENV} - DEPLOY_ENVIRONMENT: ${DEPLOY_ENVIRONMENT} - POSTHOG_API_KEY: ${POSTHOG_API_KEY} - SESSION_SECRET: ${SESSION_SECRET} - BREVO_API_KEY: ${BREVO_API_KEY} - PRISMA_POSTGRES_DIRECT_URL: ${PRISMA_POSTGRES_DIRECT_URL} - PRISMA_POSTGRES_CONNECTION_STRING: ${PRISMA_POSTGRES_CONNECTION_STRING} - TELEGRAM_BOT_API_KEY: ${TELEGRAM_BOT_API_KEY} - FRONT_WEB_APP_ORIGIN_URL: ${FRONT_WEB_APP_ORIGIN_URL} - STRIPE_API_KEY: ${STRIPE_API_KEY} - STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET} - PORT: ${PORT} - AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} - AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} - AWS_BUCKET: dev-analysis-entry-storage - AWS_REGION: ${AWS_REGION} + # server: + # container_name: server + # build: + # context: . + # dockerfile: Dockerfile.dev + # environment: + # NODE_ENV: ${NODE_ENV} + # DEPLOY_ENVIRONMENT: ${DEPLOY_ENVIRONMENT} + # POSTHOG_API_KEY: ${POSTHOG_API_KEY} + # SESSION_SECRET: ${SESSION_SECRET} + # BREVO_API_KEY: ${BREVO_API_KEY} + # PRISMA_POSTGRES_DIRECT_URL: ${PRISMA_POSTGRES_DIRECT_URL} + # PRISMA_POSTGRES_CONNECTION_STRING: ${PRISMA_POSTGRES_CONNECTION_STRING} + # TELEGRAM_BOT_API_KEY: ${TELEGRAM_BOT_API_KEY} + # FRONT_WEB_APP_ORIGIN_URL: ${FRONT_WEB_APP_ORIGIN_URL} + # STRIPE_API_KEY: ${STRIPE_API_KEY} + # STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET} + # PORT: ${PORT} + # AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} + # AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} + # AWS_BUCKET: dev-analysis-entry-storage + # S3_REGION: ${S3_REGION} + # ports: + # - 3000:3000 + # develop: + # watch: + # - path: . + # action: sync+restart #* Synchronize code changes and restart the server + # target: /usr/src/app/ + # depends_on: #* References the SERVICE name - NOT the container_name + # database: + # condition: service_started + # minio: + # condition: service_started + # networks: + # - uxcaptain-network + + minio: + image: minio/minio:latest + container_name: minio + restart: on-failure + environment: + - MINIO_ROOT_USER=${MINIO_ROOT_USER} + - MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD} + volumes: + - /Users/martaperezsanchez/repos/minio:/data ports: - - 3000:3000 - develop: - watch: - - path: . - action: sync+restart #* Synchronize code changes and restart the server - target: /usr/src/app/ - depends_on: #* References the SERVICE name - NOT the container_name - database: - condition: service_started + - 9000:9000 + - 9001:9001 + command: server /data --console-address ":9001" networks: - uxcaptain-network diff --git a/server/integrations/aws/s3.js b/server/integrations/aws/s3.js index 5b83b20..e1f6771 100644 --- a/server/integrations/aws/s3.js +++ b/server/integrations/aws/s3.js @@ -2,7 +2,7 @@ import { S3Client, GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3 import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; export const s3client = new S3Client({ - region: process.env.AWS_REGION, // irrelevant since miniIO doesnt takei into account + region: process.env.S3_REGION, // irrelevant since miniIO doesnt takei into account endpoint: 'http://localhost:9000', // Container network endpoint forcePathStyle: true, // Required for MinIO path-style URLs credentials: { From a87212b684ed373125f0c0cd8cbfe5c8e6da4c6c Mon Sep 17 00:00:00 2001 From: Sergio N Date: Fri, 26 Dec 2025 10:36:14 +0100 Subject: [PATCH 5/6] RENAME AWS_BUCKET env varibale to S3_BUCKET --- .env.example | 2 +- .kilocode/rules/memory-bank/tech.md | 2 +- compose.yaml | 2 +- server/integrations/aws/Transcribe.js | 6 +++--- server/integrations/aws/s3.js | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 3b1c228..7813a8f 100644 --- a/.env.example +++ b/.env.example @@ -22,7 +22,7 @@ PORT=3000 AWS_SECRET_ACCESS_KEY= AWS_ACCESS_KEY_ID= S3_REGION= -AWS_BUCKET= +S3_BUCKET= TRANSCRIPTION_ENABLED= diff --git a/.kilocode/rules/memory-bank/tech.md b/.kilocode/rules/memory-bank/tech.md index 1c79ee6..32c8cfc 100644 --- a/.kilocode/rules/memory-bank/tech.md +++ b/.kilocode/rules/memory-bank/tech.md @@ -90,7 +90,7 @@ PRISMA_POSTGRES_CONNECTION_STRING=postgresql://user:password@localhost:5432/uxca AWS_ACCESS_KEY_ID=your-access-key AWS_SECRET_ACCESS_KEY=your-secret-key S3_REGION=eu-west-3 -AWS_BUCKET=your-bucket-name +S3_BUCKET=your-bucket-name # Stripe STRIPE_API_KEY=sk_test_... diff --git a/compose.yaml b/compose.yaml index 45d6de1..f18bdce 100644 --- a/compose.yaml +++ b/compose.yaml @@ -20,7 +20,7 @@ services: # PORT: ${PORT} # AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} # AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} - # AWS_BUCKET: dev-analysis-entry-storage + # S3_BUCKET: dev-analysis-entry-storage # S3_REGION: ${S3_REGION} # ports: diff --git a/server/integrations/aws/Transcribe.js b/server/integrations/aws/Transcribe.js index fe225ea..569f3ee 100644 --- a/server/integrations/aws/Transcribe.js +++ b/server/integrations/aws/Transcribe.js @@ -7,16 +7,16 @@ import { import { getS3Object } from './s3.js'; import { logInfo } from '../../config/loggerFunctions.js'; -const transcribeClient = new TranscribeClient({ region: process.env.AWS_REGION }); +const transcribeClient = new TranscribeClient({ region: process.env.S3_REGION }); export const requestAnalysisEntryTranscriptionToAWSTranscribe = async (transcriptionRequest) => { const command = new StartTranscriptionJobCommand({ TranscriptionJobName: transcriptionRequest.analysisEntryId, LanguageCode: transcriptionRequest.languageCode, Media: { - MediaFileUri: `s3://${process.env.AWS_BUCKET}/analysis/${transcriptionRequest.analysisId}/${transcriptionRequest.analysisEntryId}/recording.mp4`, + MediaFileUri: `s3://${process.env.S3_BUCKET}/analysis/${transcriptionRequest.analysisId}/${transcriptionRequest.analysisEntryId}/recording.mp4`, }, - OutputBucketName: process.env.AWS_BUCKET, + OutputBucketName: process.env.S3_BUCKET, OutputKey: `analysis/${transcriptionRequest.analysisId}/${transcriptionRequest.analysisEntryId}/transcription.json`, }); diff --git a/server/integrations/aws/s3.js b/server/integrations/aws/s3.js index e1f6771..2331837 100644 --- a/server/integrations/aws/s3.js +++ b/server/integrations/aws/s3.js @@ -13,7 +13,7 @@ export const s3client = new S3Client({ export const generateS3GetPresignedUrl = async (key) => { const command = new GetObjectCommand({ - Bucket: process.env.AWS_BUCKET, + Bucket: process.env.S3_BUCKET, Key: key, }); @@ -24,7 +24,7 @@ export const generateS3GetPresignedUrl = async (key) => { export const generateS3PutPresignedUrl = async (key) => { const command = new PutObjectCommand({ - Bucket: process.env.AWS_BUCKET, + Bucket: process.env.S3_BUCKET, Key: key, ContentType: 'video/mp4', }); @@ -38,7 +38,7 @@ export const generateS3PutPresignedUrl = async (key) => { export const getS3Object = async (key) => { const command = new GetObjectCommand({ - Bucket: process.env.AWS_BUCKET, + Bucket: process.env.S3_BUCKET, Key: key, }); From 19d6f370d35863fb174124ae247223b1d78dabed Mon Sep 17 00:00:00 2001 From: Sergio N Date: Fri, 26 Dec 2025 11:44:52 +0100 Subject: [PATCH 6/6] UPDATE s3 endpoint to be an env variable instead of hardcoded --- .env.example | 1 + server/integrations/aws/s3.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 7813a8f..c098c48 100644 --- a/.env.example +++ b/.env.example @@ -23,6 +23,7 @@ AWS_SECRET_ACCESS_KEY= AWS_ACCESS_KEY_ID= S3_REGION= S3_BUCKET= +S3_ENDPOINT= TRANSCRIPTION_ENABLED= diff --git a/server/integrations/aws/s3.js b/server/integrations/aws/s3.js index 2331837..94c1168 100644 --- a/server/integrations/aws/s3.js +++ b/server/integrations/aws/s3.js @@ -3,7 +3,7 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; export const s3client = new S3Client({ region: process.env.S3_REGION, // irrelevant since miniIO doesnt takei into account - endpoint: 'http://localhost:9000', // Container network endpoint + endpoint: process.env.S3_ENDPOINT, // Container network endpoint forcePathStyle: true, // Required for MinIO path-style URLs credentials: { accessKeyId: process.env.MINIO_ROOT_USER,