-
Notifications
You must be signed in to change notification settings - Fork 1
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 #391 from TripInfoWeb/dev_refactoring
Refactor: 코드 스타일 통일
- Loading branch information
Showing
119 changed files
with
1,314 additions
and
1,282 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"semi": "error", | ||
"quotes": "error", | ||
"jsx-quotes": "error", | ||
"indent": [ | ||
"error", | ||
2, | ||
{ | ||
"SwitchCase": 1 // Switch 문을 사용할 때 case가 switch보다 한 단계 들여쓰기되도록 합니다. | ||
} | ||
], | ||
"no-tabs": "error", | ||
"max-len": "off" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,39 +1,48 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
interface BookmarkRequestBody { | ||
isBookmarked: boolean; | ||
isBookmarked: boolean; | ||
} | ||
|
||
// POST 요청을 처리하는 함수 | ||
export async function POST(request: NextRequest) { | ||
const access_cookie = request.cookies.get("access_token"); | ||
if (!access_cookie) { | ||
const refresh_cookie = request.cookies.get("refresh_token"); | ||
if (!refresh_cookie) { | ||
// 리프레시 토큰이 없으므로 요청 중단 | ||
return new NextResponse("Refresh token not found", { status: 403 }); | ||
} | ||
// 리프레시 토큰으로 재발급 받아 재요청 보내기 위한 응답 | ||
return new NextResponse("Unauthorized", { status: 401 }); | ||
const access_cookie = request.cookies.get("access_token"); | ||
if (!access_cookie) { | ||
const refresh_cookie = request.cookies.get("refresh_token"); | ||
if (!refresh_cookie) { | ||
// 리프레시 토큰이 없으므로 요청 중단 | ||
return new NextResponse("Refresh token not found", { status: 403 }); | ||
} | ||
|
||
try { | ||
// 요청 바디 파싱 | ||
const { isBookmarked }: BookmarkRequestBody = await request.json(); | ||
const response = await fetch(`${process.env.BACKEND_URL}/api/gatherings/bookmark`, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ isBookmarked }) | ||
}); | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return NextResponse.json({ message: 'Bookmark status updated successfully' }, { status: 200 }); | ||
} catch (error) { | ||
// 에러 응답 반환 | ||
return NextResponse.json({ message: 'Internal Server Error' }, { status: 500 }); | ||
// 리프레시 토큰으로 재발급 받아 재요청 보내기 위한 응답 | ||
return new NextResponse("Unauthorized", { status: 401 }); | ||
} | ||
|
||
try { | ||
// 요청 바디 파싱 | ||
const { isBookmarked }: BookmarkRequestBody = await request.json(); | ||
|
||
const response = await fetch( | ||
`${process.env.BACKEND_URL}/api/gatherings/bookmark`, | ||
{ | ||
method: "POST", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ isBookmarked }), | ||
}, | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error("Network response was not ok"); | ||
} | ||
|
||
return NextResponse.json( | ||
{ message: "Bookmark status updated successfully" }, | ||
{ status: 200 }, | ||
); | ||
} catch (error) { | ||
// 에러 응답 반환 | ||
return NextResponse.json( | ||
{ message: "Internal Server Error" }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
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.