-
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.
* add :: user api * chore :: code format * chore :: code format * bug :: promise fending resolve * chore :: http method * bug :: update query * add :: upload profile * add :: query user info api * add :: update user info api * chore :: code format
- Loading branch information
Showing
10 changed files
with
545 additions
and
12 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
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,9 +1,31 @@ | ||
import { int } from "aws-sdk/clients/datapipeline"; | ||
import { IsNotEmpty, IsNumber, IsString, Matches } from "class-validator"; | ||
|
||
export class QueryApplyFriendListResponse { | ||
users: FriendListElement[] | ||
} | ||
|
||
export class FriendListElement { | ||
id: string | ||
nickname: string | ||
profile: string | ||
isTurnOn: boolean | ||
} | ||
|
||
export class QueryUserInfoResponse { | ||
id: string | ||
nickname: string | ||
email: string | ||
point: number | ||
profile: string | ||
} | ||
|
||
export class UpdateUserRequest { | ||
@Matches(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/, { | ||
message: '유효한 이메일 주소를 입력해주세요.', | ||
}) | ||
email: string; | ||
@IsNotEmpty() | ||
@IsString() | ||
nickname: 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
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,3 @@ | ||
import { AuthGuard } from "@nestjs/passport"; | ||
|
||
export class JwtGuard extends AuthGuard('jwt') {} |
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 { HttpException, Injectable } from "@nestjs/common"; | ||
import { ConfigService } from "@nestjs/config"; | ||
import * as AWS from 'aws-sdk'; | ||
|
||
@Injectable() | ||
export class AwsService { | ||
private s3Client | ||
constructor(private config: ConfigService) { | ||
this.s3Client = new AWS.S3({ | ||
accessKeyId: config.get('AWS_S3_ACCESS_KEY'), | ||
secretAccessKey: config.get('AWS_S3_SECRET_KEY'), | ||
region: config.get('AWS_S3_REGION'), | ||
}); | ||
} | ||
async upload(fileName: string, file) { | ||
const allowedExtensions = ['jpg', 'jpeg', 'png', 'gif']; | ||
|
||
const extension = file.originalname.split('.').pop() | ||
|
||
if (!allowedExtensions.includes(extension)) { | ||
throw new HttpException('Unsupported file extension', 400); | ||
} | ||
const command = { | ||
Bucket: this.config.get('AWS_S3_BUCKET_NAME'), | ||
Key: fileName, | ||
Body: file.buffer, | ||
ACL: 'public-read', | ||
ContentType: file.mimeType, | ||
} | ||
|
||
await this.s3Client.upload(command).promise() | ||
|
||
return `https://s3.${this.config.get('AWS_S3_REGION')}.amazonaws.com/${this.config.get('AWS_S3_BUCKET_NAME')}/${fileName}`; | ||
} | ||
} |