Skip to content

Commit

Permalink
feat: aws s3 module allows all options
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin committed Oct 9, 2023
1 parent d57e668 commit 50a7210
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 41 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ignore-workspace-root-check=true
shamefully-hoist=true
strict-peer-dependencies=false
auto-install-peers=true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"nestjs-minio": "^2.5.1",
"nestjs-pino": "^3.5.0",
"nestjs-throttler-storage-redis": "^0.4.1",
"nodemailer": "^6.9.5",
"nodemailer": "^6.9.6",
"otplib": "^12.0.1",
"passport": "0.6.0",
"passport-facebook": "^3.0.0",
Expand Down
53 changes: 26 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/lib/aws/aws.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ObjectCannedACL } from "@aws-sdk/client-s3";
import type { ObjectCannedACL, S3ClientConfig } from "@aws-sdk/client-s3";

export interface AwsS3 {
baseUrl: string
Expand All @@ -19,10 +19,7 @@ export interface AwsS3PutItemOptions {
keepOriginalName?: boolean
}

export interface AwsModuleOptions {
accessKeyId: string
baseUrl: string
export interface AwsModuleOptions extends S3ClientConfig {
bucket: string
secretAccessKey: string
region: string
baseUrl: string
}
9 changes: 2 additions & 7 deletions src/lib/aws/aws.s3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { Inject, Injectable } from "@nestjs/common";
import { lookup } from "mime-types";

import { omit } from "helper-fns";
import type {
AwsS3,
AwsS3MultiPart,
Expand All @@ -35,13 +36,7 @@ export class AwsS3Service {
@Inject(MODULE_OPTIONS_TOKEN)
private readonly options: AwsModuleOptions,
) {
this.s3Client = new S3Client({
credentials: {
accessKeyId: this.options.accessKeyId,
secretAccessKey: this.options.secretAccessKey,
},
region: this.options.region,
});
this.s3Client = new S3Client(omit(options, ["bucket", "baseUrl"]));

this.bucket = this.options.bucket;
this.baseUrl = this.options.baseUrl;
Expand Down

0 comments on commit 50a7210

Please sign in to comment.