-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
13 changed files
with
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { NextResponse } from "next/server"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
export async function POST(request: NextRequest) { | ||
try { | ||
// 요청 바디를 JSON 형식으로 파싱 | ||
const { uuid, name, password, bookmarkUrls, storeUrls } = | ||
await request.json(); | ||
|
||
// 유효성 검사 | ||
if ( | ||
!uuid || | ||
!name || | ||
!password || | ||
!Array.isArray(bookmarkUrls) || | ||
!Array.isArray(storeUrls) | ||
) { | ||
return NextResponse.json( | ||
{ error: "필수 필드가 누락되었거나 형식이 잘못되었습니다." }, | ||
{ status: 400 } | ||
); | ||
} | ||
|
||
// 비밀번호 길이 검사 | ||
if (password.length !== 4 || !/^\d+$/.test(password)) { | ||
return NextResponse.json( | ||
{ error: "비밀번호는 4자리 숫자여야 합니다." }, | ||
{ status: 400 } | ||
); | ||
} | ||
|
||
// 요청이 성공적으로 처리된 경우 | ||
const responseData = { | ||
message: "성공적으로 처리되었습니다.", | ||
data: { | ||
uuid, | ||
name, | ||
bookmarkUrls, | ||
storeUrls, | ||
}, | ||
}; | ||
|
||
return NextResponse.json(responseData, { status: 200 }); | ||
} catch (error) { | ||
// 오류 처리 | ||
return NextResponse.json( | ||
{ error: "서버 오류가 발생했습니다." }, | ||
{ status: 500 } | ||
); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
File renamed without changes.
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
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
File renamed without changes.
File renamed without changes.