Skip to content

Conversation

@ConradOsvik
Copy link
Collaborator

Summary

Implements MinIO S3-compatible object storage for file uploads, addressing the infrastructure requirements for handling user-generated content.

Changes

  • Storage Service: Created src/lib/storage/ with S3-compatible client supporting upload, download, delete, and exists operations
  • Context Integration: Added bucket to AppContext, accessible via c.get('ctx').bucket in all routes
  • Docker Setup: Added MinIO service to dev and prod docker-compose configurations
  • Environment Config: Added MinIO connection variables with sensible defaults
  • Testing Support: Integrated MinIO testcontainer for isolated test environments

Usage Example

export default route().post('/', async (c) => {
  const { bucket } = c.get('ctx')
  
  // Upload a file
  const key = await bucket.upload('images/photo.jpg', fileBuffer, 'image/jpeg')
  
  // Download a file
  const file = await bucket.download('images/photo.jpg')
  
  // Check if exists
  const exists = await bucket.exists('images/photo.jpg')
  
  // Delete a file
  await bucket.delete('images/photo.jpg')
})

Test plan

  • Type checking passes
  • Linting passes
  • MinIO testcontainer integration complete
  • Run pnpm docker:dev to verify MinIO starts correctly
  • Access MinIO console at http://localhost:9001
  • Run integration tests to verify testcontainer setup

Closes #66

Add @aws-sdk/client-s3 and @testcontainers/minio for S3-compatible
object storage support
Create storage service with S3-compatible client supporting:
- File upload with content type
- File download as Buffer
- File deletion
- File existence checks
- Automatic bucket creation and management
Add configuration for MinIO connection:
- MINIO_ENDPOINT (default: localhost:9000)
- MINIO_ROOT_USER (default: minioadmin)
- MINIO_ROOT_PASSWORD (default: minioadmin)
- MINIO_BUCKET_NAME (default: photon-files)
- MINIO_USE_SSL (default: false)
Add MinIO service to dev and prod environments:
- API port 9000, console port 9001
- Persistent volume for data storage
- Health checks for container readiness
- Environment-based credentials configuration
Add bucket storage client to AppContext, making it accessible via
c.get('ctx').bucket in all routes following the same pattern as db
and redis
Integrate MinIO testcontainer into test setup:
- Parallel container initialization with PostgreSQL and Redis
- Automatic bucket creation for tests
- Bucket reset between tests for isolation
- Proper cleanup on test completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File uploads

2 participants