-
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.
Merge pull request #8 from Deumjubukeo/origin/feature/profile
Origin/feature/profile + img upload
- Loading branch information
Showing
15 changed files
with
2,183 additions
and
1,994 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AwsService } from './aws.service'; | ||
import { ConfigModule } from '@nestjs/config'; | ||
|
||
@Module({ | ||
imports: [ConfigModule], | ||
providers: [AwsService], | ||
exports: [AwsService], | ||
}) | ||
export class AwsModule {} |
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,31 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'; | ||
|
||
@Injectable() | ||
export class AwsService { | ||
s3Client: S3Client; | ||
|
||
constructor(private configService: ConfigService) { | ||
this.s3Client = new S3Client({ | ||
region: this.configService.get('AWS_REGION'), | ||
}); | ||
} | ||
|
||
async imageUploadToS3( | ||
fileName: string, | ||
file: Express.Multer.File, | ||
ext: string, | ||
) { | ||
const command = new PutObjectCommand({ | ||
Bucket: this.configService.get('AWS_S3_BUCKET_NAME'), | ||
Key: fileName, | ||
Body: file.buffer, | ||
ACL: 'public-read', | ||
ContentType: `image/${ext}`, | ||
}); | ||
|
||
await this.s3Client.send(command); | ||
return `https://s3.${process.env.AWS_REGION}.amazonaws.com/${process.env.AWS_S3_BUCKET_NAME}/${fileName}`; | ||
} | ||
} |
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,15 +1,19 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
// @ts-ignore | ||
import { IsString, IsNumber, IsOptional } from 'class-validator'; | ||
|
||
export class CreateGoodsDto { | ||
@ApiProperty({ description: '제목' }) | ||
@IsString() | ||
title: string; | ||
|
||
@ApiProperty({ description: '내용' }) | ||
@IsString() | ||
content: string; | ||
|
||
@ApiProperty({ description: '가격' }) | ||
pize: number; | ||
@IsNumber() | ||
price: number; | ||
|
||
@ApiProperty({ description: '이미지' }) | ||
imageUrl: string; | ||
@IsOptional() | ||
imageUrl?: string; | ||
|
||
@IsNumber() | ||
purchaseCount: number; | ||
} |
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
Oops, something went wrong.