-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
124a9f9
commit 6ea22db
Showing
12 changed files
with
405 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { IsString, IsUrl, IsNotEmpty } from 'class-validator'; | ||
|
||
export class Enviroments { | ||
@IsString() | ||
@IsNotEmpty() | ||
WASABI_ACCESS_KEY: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
WASABI_SECRET_KEY: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
WASABI_REGION: string; | ||
|
||
@IsUrl() | ||
@IsNotEmpty() | ||
WASABI_ENDPOINT: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
THUMB_BUCKET: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
BACKGROUND_BUCKET: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
COMPONENT_BUCKET: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
LETTER_BUCKET: string; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { StorageService } from "@storage/storage.service"; | ||
import { Injectable } from "@nestjs/common"; | ||
|
||
@Injectable() | ||
export class LetterService { | ||
|
||
constructor( | ||
private readonly storage: StorageService | ||
) {} | ||
} |
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,9 @@ | ||
import { Global, Module } from "@nestjs/common"; | ||
import { StorageService } from "./storage.service"; | ||
|
||
@Global() | ||
@Module({ | ||
providers : [StorageService], | ||
exports : [StorageService] | ||
}) | ||
export class StorageModule{} |
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 { Injectable } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import * as AWS from 'aws-sdk'; | ||
|
||
@Injectable() | ||
export class StorageService { | ||
private s3: AWS.S3; | ||
|
||
constructor(private readonly configService: ConfigService) { | ||
this.s3 = new AWS.S3({ | ||
accessKeyId: this.configService.get<string>('WASABI_ACCESS_KEY'), | ||
secretAccessKey: this.configService.get<string>('WASABI_SECRET_KEY'), | ||
region: this.configService.get<string>('WASABI_REGION'), | ||
endpoint: this.configService.get<string>('WASABI_ENDPOINT'), | ||
s3ForcePathStyle: true, | ||
}); | ||
} | ||
|
||
async generateUploadPresignedUrl(param : {bucket: string, key: string, expires: number }): Promise<string> { | ||
const params = { | ||
Bucket: param.bucket, | ||
Key: param.key, | ||
Expires: param.expires, | ||
ContentType: 'application/octet-stream', | ||
}; | ||
|
||
return await this.s3.getSignedUrlPromise('putObject', params); | ||
} | ||
|
||
async generateDownloadPresignedUrl(param : {bucket: string, key: string, expires: number }): Promise<string> { | ||
const params = { | ||
Bucket: param.bucket, | ||
Key: param.key, | ||
Expires: param.expires, | ||
}; | ||
|
||
return await this.s3.getSignedUrlPromise('getObject', params); | ||
} | ||
} |
File renamed without changes.
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
Oops, something went wrong.