Skip to content

Conversation

@roderik
Copy link
Member

@roderik roderik commented Oct 1, 2024

Summary by Sourcery

Add support for generating a MinIO S3 client in the SettleMint SDK, enabling integration with MinIO storage services. Update the code generation process to incorporate MinIO configuration when present.

New Features:

  • Introduce a MinIO S3 client generation capability in the SettleMint SDK, allowing integration with MinIO storage services.

Enhancements:

  • Update the code generation command to include MinIO configuration if available, enhancing the SDK's flexibility.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 1, 2024

Reviewer's Guide by Sourcery

This pull request implements the generation of a Minio client for S3-compatible storage in the SettleMint SDK. It adds support for Minio configuration in the SDK generation process and includes necessary changes to integrate Minio functionality into the existing codebase.

Sequence Diagram

sequenceDiagram
    participant User
    participant CodegenCommand
    participant SDKGenerator
    participant MinioClient

    User->>CodegenCommand: Run codegen command
    CodegenCommand->>SDKGenerator: Generate SDK
    alt Minio configuration exists
        SDKGenerator->>MinioClient: Create Minio S3 client
        MinioClient-->>SDKGenerator: Return Minio client
    end
    SDKGenerator-->>CodegenCommand: Return generated SDK
    CodegenCommand-->>User: SDK generated successfully
Loading

File-Level Changes

Change Details Files
Add Minio client generation to the SDK
  • Extract 'minio' from application configuration
  • Add conditional creation of Minio S3 client
  • Update SDK generator export to include Minio client creation
  • Modify connectSettlemint function signature to accept Minio configuration
packages/cli/src/commands/codegen.ts
packages/next/src/browser/sdk/sdk.ts
Implement Minio S3 client creation function
  • Create new file for Minio client implementation
  • Implement createMinioS3Client function using Minio library
  • Use environment variables for Minio access and secret keys
packages/next/src/browser/sdk/plugins/minio.ts
Add Minio codegen support
  • Create new file for Minio codegen functionality
  • Implement createMinioS3Client function for SDK generation
packages/cli/src/lib/codegen/minio.ts
Remove LOCAL_HASURA environment variable usage
  • Replace process.env.LOCAL_HASURA ?? hasuraGql with just hasuraGql
packages/cli/src/commands/codegen.ts
packages/next/src/node/next/with-settlemint.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the feat New feature label Oct 1, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @roderik - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider making the Minio client port and SSL usage configurable instead of hardcoding them.
  • It might be beneficial to document the new SETTLEMINT_MINIO_ACCESS_KEY and SETTLEMINT_MINIO_SECRET_KEY environment variables, and possibly explore more secure ways of handling these credentials.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Review instructions: 2 issues found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -0,0 +1,11 @@
import { Client } from "minio";

export function createMinioS3Client({ endPoint }: { endPoint: string }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (review_instructions): Consider adding error handling for potential connection issues.

While the code is functional, it might be beneficial to add error handling to manage potential connection failures or invalid credentials. This would improve the robustness of the function.

export function createMinioS3Client({ endPoint }: { endPoint: string }): Promise<Client> {
  return new Promise((resolve, reject) => {
    try {
      const client = new Client({
        endPoint: endPoint,
        // ... other configuration options
      });
      resolve(client);
    } catch (error) {
      reject(new Error(`Failed to create Minio S3 client: ${error.message}`));
    }
  });
}
Review instructions:

Path patterns: **/*.ts

Instructions:

  • You always use the latest version of NodeJS, Bun, React, NestJS and NextJS, and you are familiar with the latest features and best practices.
  • Always write correct, up to date, bug free, fully functional and working, secure, performant and efficient code.
  • Focus on readability over being performant, but performance is important.

Comment on lines +8 to +9
accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY ?? "",
secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY ?? "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (review_instructions): Consider adding validation for required environment variables.

It's a good practice to validate that these environment variables are set before using them. If they're required for the client to function correctly, you might want to throw an error if they're not present.

const accessKey = process.env.SETTLEMINT_MINIO_ACCESS_KEY;
const secretKey = process.env.SETTLEMINT_MINIO_SECRET_KEY;

if (!accessKey || !secretKey) {
  throw new Error('Minio access key and secret key are required');
}

accessKey: accessKey,
secretKey: secretKey,
Review instructions:

Path patterns: **/*.ts

Instructions:

  • You always use the latest version of NodeJS, Bun, React, NestJS and NextJS, and you are familiar with the latest features and best practices.
  • Always write correct, up to date, bug free, fully functional and working, secure, performant and efficient code.
  • Focus on readability over being performant, but performance is important.

Comment on lines +6 to +7
port: 443,
useSSL: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Make port and SSL settings configurable

The hardcoded port and SSL settings might not be flexible enough for all use cases. Consider making these configurable by accepting them as parameters or reading from configuration.

export function createMinioS3Client({ endPoint, port = 443, useSSL = true }: { endPoint: string; port?: number; useSSL?: boolean }) {
  return new Client({
    endPoint: endPoint,
    port,
    useSSL,
    accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY ?? "",
    secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY ?? "",

@github-actions
Copy link

github-actions bot commented Oct 1, 2024

📦 Packages

Package Version
SDK Cli @settlemint/sdk-cli@0.4.29-prf0ec852
SDK Config @settlemint/sdk-config@0.4.29-prf0ec852
SDK Next @settlemint/sdk-next@0.4.29-prf0ec852

@roderik roderik merged commit f0ef11f into main Oct 1, 2024
@roderik roderik deleted the feat/generate-minio-client branch October 1, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants