-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
MinIO
for object storage (#365)
* feat: integrate MinIO for file storage - Add MinIO support in FilesService - Update docker-compose.yml to include MinIO service - Implement environment variable switching between S3 and MinIO - Add MinIO endpoint configuration - Update documentation for MinIO setup and usage * feat: Add storage module for file upload - Add storage module to handle file upload functionality - Configure S3Client for storage service - Update files service to use injected S3Client - Update files module to import storage module * refactor: storage module to remove unnecessary credentials case by aws_s3 * refactor: storage module update condition check logic to use file_upload variable * feat: set default configuration values for Minio * refactor: update storage module to remove default value for AWS_REGION * refactor: remove unused StorageType enum * refactor: update .env.development to set default values for Minio * feat: enhance file upload configuration for MinIO support * refactor: update .env.development with detailed comments for MinIO configuration * refactor: update .env.development for MinIO configuration with specific values * refactor: update docker-compose configuration for MinIO file upload * refactor: update file upload configuration type check in storage module * refactor: update file upload configuration to enable based on false check * feat: integrate MinIO for file storage - Add MinIO support in FilesService - Update docker-compose.yml to include MinIO service - Implement environment variable switching between S3 and MinIO - Add MinIO endpoint configuration - Update documentation for MinIO setup and usage * Feat configure MinIO for file storage and update environment variables * Reformat code * Remove redundant `links` field in `docker-compose` * Add dependant condition * Remove unused functions * Remove unused file --------- Co-authored-by: devleejb <[email protected]>
- Loading branch information
Showing
9 changed files
with
2,000 additions
and
1,865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { S3Client, S3ClientConfig } from "@aws-sdk/client-s3"; | ||
import { Module } from "@nestjs/common"; | ||
import { ConfigService } from "@nestjs/config"; | ||
|
||
const s3ClientFactory = { | ||
provide: "STORAGE_CLIENT", | ||
useFactory: (configService: ConfigService): S3Client | null => { | ||
const fileUpload = configService.get<"false" | "s3" | "minio">("FILE_UPLOAD"); | ||
if (fileUpload === "false") { | ||
return null; | ||
} | ||
|
||
const region = configService.get<string>("AWS_REGION"); | ||
const endpoint = configService.get<string>("MINIO_ENDPOINT"); | ||
const accessKeyId = configService.get<string>("MINIO_ACCESS_KEY"); | ||
const secretAccessKey = configService.get<string>("MINIO_SECRET_KEY"); | ||
|
||
const config: S3ClientConfig = { | ||
region, | ||
...(fileUpload === "minio" && { | ||
endpoint, | ||
forcePathStyle: true, | ||
credentials: { | ||
accessKeyId, | ||
secretAccessKey, | ||
}, | ||
}), | ||
}; | ||
|
||
return new S3Client(config); | ||
}, | ||
inject: [ConfigService], | ||
}; | ||
|
||
@Module({ | ||
providers: [s3ClientFactory], | ||
exports: [s3ClientFactory], | ||
}) | ||
export class StorageModule {} |
Oops, something went wrong.