-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
장소에 색상 추가 #100
Merged
Merged
장소에 색상 추가 #100
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8cb99ff
refatcor: 유저 enum, type 파일명 수정
Miensoap ec3f1f6
feat: 장소에 색상 추가, 맵에 장소 등록시 사용 #86
Miensoap 0ac057e
refactor: 전역예외필터 타입별로 분리
Miensoap 40325e8
fix: 내용이 없는 페이지 요청에 대해 빈 배열 응답하도록 수정
Miensoap ad2ffb1
style: 코드 포맷팅
Miensoap 87a9083
feat: 핀 색상 컬럼에 NOT NULL 제약조건 추가 #86
Miensoap 1020a66
refactor: 코스/지도에 장소 추가 전 확인 메서드명 수정 #86
Miensoap 12a4b4a
feat: 이미지 업로드 관련 Cloud Functions
Miensoap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function main(params) { | ||
const AWS = require('aws-sdk'); | ||
|
||
const ENDPOINT_URL = 'https://kr.object.ncloudstorage.com'; | ||
const endpoint = new AWS.Endpoint('https://kr.object.ncloudstorage.com'); | ||
const region = 'kr-standard'; | ||
const accessKey = params.access; | ||
const secretKey = params.secret; | ||
|
||
const bucketName = 'ogil-public'; | ||
const baseDirname = 'uploads'; | ||
|
||
const objectName = path.join( | ||
'post', | ||
baseDirname, | ||
params.dirname, | ||
getUUIDName(params.extension), | ||
); | ||
|
||
const signedUrlExpireSeconds = 300; | ||
const contentType = 'image/*'; | ||
const ACL = 'public-read'; | ||
|
||
const maxFileSize = 3 * 1024 * 1024; | ||
|
||
const S3 = new AWS.S3({ | ||
endpoint: endpoint, | ||
region: region, | ||
credentials: { | ||
accessKeyId: accessKey, | ||
secretAccessKey: secretKey, | ||
}, | ||
signatureVersion: 'v4', | ||
}); | ||
|
||
const post = S3.createPresignedPost({ | ||
Bucket: bucketName, | ||
Conditions: [['content-length-range', 0, maxFileSize]], | ||
ContentType: contentType, | ||
Expires: signedUrlExpireSeconds, | ||
Fields: { | ||
key: objectName, | ||
'Content-Type': contentType, | ||
acl: ACL, | ||
}, | ||
}); | ||
|
||
const uploadedUrl = path.join(ENDPOINT_URL, bucketName, objectName); | ||
|
||
console.log(post); | ||
console.log(`${uploadedUrl}에 업로드 됩니다`); | ||
|
||
return { ...post, uploadedUrl }; | ||
} | ||
|
||
function getUUIDName(extension) { | ||
const { v4: uuidv4 } = require('uuid'); | ||
return uuidv4().substring(0, 13).replace('-', '') + '.' + extension; | ||
} |
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,50 @@ | ||
function main(params) { | ||
const AWS = require('aws-sdk'); | ||
|
||
const ENDPOINT_URL = 'https://kr.object.ncloudstorage.com'; | ||
const endpoint = new AWS.Endpoint('https://kr.object.ncloudstorage.com'); | ||
const region = 'kr-standard'; | ||
const accessKey = params.access; | ||
const secretKey = params.secret; | ||
|
||
const bucketName = 'ogil-public'; | ||
const baseDirname = 'uploads'; | ||
|
||
const objectName = path.join( | ||
baseDirname, | ||
params.dirname, | ||
getUUIDName(params.extension), | ||
); | ||
|
||
const signedUrlExpireSeconds = 300; | ||
const contentType = 'image/*'; | ||
const ACL = 'public-read'; | ||
|
||
const S3 = new AWS.S3({ | ||
endpoint: endpoint, | ||
region: region, | ||
credentials: { | ||
accessKeyId: accessKey, | ||
secretAccessKey: secretKey, | ||
}, | ||
signatureVersion: 'v4', | ||
}); | ||
|
||
const url = S3.getSignedUrl('putObject', { | ||
Bucket: bucketName, | ||
Key: objectName, | ||
Expires: signedUrlExpireSeconds, | ||
ContentType: contentType, | ||
ACL, | ||
}); | ||
|
||
const uploadedUrl = path.join(ENDPOINT_URL, bucketName, objectName); | ||
|
||
console.log({ url, uploadedUrl }); | ||
return { url, uploadedUrl }; | ||
} | ||
|
||
function getUUIDName(extension) { | ||
const { v4: uuidv4 } = require('uuid'); | ||
return uuidv4().substring(0, 13).replace('-', '') + '.' + extension; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { IsNumber, IsString } from 'class-validator'; | ||
import { IsNumber, IsString, IsEnum } from 'class-validator'; | ||
import { Color } from '../../place/color.enum'; | ||
|
||
export class AddPlaceToMapRequest { | ||
@IsNumber() | ||
placeId: number; | ||
|
||
@IsString() | ||
comment?: string; | ||
|
||
@IsEnum(Color) | ||
color: Color; | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q:
BaseException
이HttpException
을 상속받기 때문에 실행 순서가 중요할 것 같은데요.Filter
가 순서가 적용되는지 확인을 해야할 것 같습니다. 순서가 적용된다면 순서도 바꿔야 겠네요.제가 테스트 했을 때는 효과가 없었던 것 같아서
GlobalExceptionFilter
에서if
로 구분했었거든요. 한번 확인해보고 알려주세요!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 PR 메시지에 적었는데요,
당연히 좁은 범위를 먼저 선언해야 할 것 같지만
반대로 넓은 범위를 먼저 선언해야 제대로 작동하더라구요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉 충격적이군요 좋습니다