-
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 #33 from Leets-Official/feat-32-채팅api연결
#32 채팅api연결
- Loading branch information
Showing
66 changed files
with
1,260 additions
and
781 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,17 @@ | ||
import { Server as HTTPServer } from 'http'; | ||
import { NextApiResponse } from 'next'; | ||
import { Server as SocketIOServer } from 'socket.io'; | ||
|
||
export type NextApiResponseServerIO = NextApiResponse & { | ||
socket: { | ||
server: HTTPServer & { | ||
io: SocketIOServer; | ||
}; | ||
}; | ||
}; | ||
|
||
export interface Message { | ||
user: string; | ||
text: string; | ||
timestamp: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { unFollowUser } from '@/app/service/deleteRequest'; | ||
import { followUser } from '@/app/service/postRequest'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function POST(req: Request) { | ||
const data = await req.json(); | ||
|
||
const response = await followUser(data, req); | ||
return NextResponse.json(response); | ||
} | ||
|
||
export async function DELETE(req: Request) { | ||
const { searchParams } = new URL(req.url); | ||
const tag = searchParams.get('tag') || ''; | ||
|
||
const response = await unFollowUser(tag, req); | ||
return NextResponse.json(response); | ||
} |
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,44 +1,12 @@ | ||
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER; | ||
import { getFollowers } from '@/app/service/getRequest'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
import { Follower } from "@/app/_types/main"; | ||
export async function GET(req: Request) { | ||
const { searchParams } = new URL(req.url); | ||
|
||
interface APIResponse { | ||
success: boolean; | ||
data: { | ||
userId: string; | ||
nickname: string; | ||
tag: string; | ||
profile: string; | ||
bio?: string; | ||
}[]; | ||
errorCode: number | null; | ||
errorMessage: string | null; | ||
} | ||
const tag = searchParams.get('tag') || ''; | ||
|
||
const response = await getFollowers(req, tag); | ||
|
||
export const fetchFollowers = async (tag: string): Promise<Follower[]> => { | ||
try { | ||
const response = await fetch(`${SERVER_URL}/api/follows/followers?tag=${tag}`); | ||
|
||
if (!response.ok) { | ||
throw new Error('API 호출에 실패했습니다'); | ||
} | ||
|
||
const data: APIResponse = await response.json(); | ||
|
||
if (!data.success) { | ||
throw new Error(data.errorMessage || '팔로워 목록을 불러오는데 실패했습니다'); | ||
} | ||
|
||
return data.data.map(item => ({ | ||
id: item.userId, | ||
name: item.nickname, | ||
username: `@${item.tag}`, | ||
bio: item.bio || '', | ||
profile: item.profile, | ||
isFollowing: false, | ||
})); | ||
} catch (error) { | ||
console.error('Fetch error:', error); | ||
throw error; | ||
} | ||
}; | ||
return NextResponse.json(response); | ||
} |
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,76 +1,12 @@ | ||
const SERVER_URL = process.env.NEXT_PUBLIC_SERVER ; | ||
import { getFollowing } from '@/app/service/getRequest'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export interface Following { | ||
id: string; | ||
name: string; | ||
username: string; | ||
bio: string; | ||
profile: string; | ||
} | ||
|
||
interface APIResponse { | ||
success: boolean; | ||
data: { | ||
id: number; | ||
tag: string; | ||
nickname: string; | ||
profile?: string; | ||
bio?: string; | ||
}[]; | ||
errorCode: number | null; | ||
errorMessage: string | null; | ||
} | ||
export async function GET(req: Request) { | ||
const { searchParams } = new URL(req.url); | ||
|
||
export const fetchFollowings = async (tag: string): Promise<Following[]> => { | ||
try { | ||
const response = await fetch(`${SERVER_URL}/api/follows/followings?tag=${tag}`); | ||
|
||
if (!response.ok) { | ||
throw new Error('API 호출에 실패했습니다'); | ||
} | ||
|
||
const data: APIResponse = await response.json(); | ||
|
||
if (!data.success) { | ||
throw new Error(data.errorMessage || '팔로잉 목록을 불러오는데 실패했습니다'); | ||
} | ||
|
||
return data.data.map(item => ({ | ||
id: item.id.toString(), | ||
name: item.nickname, | ||
username: `@${item.tag}`, | ||
bio: item.bio || '', | ||
profile: item.profile || '', | ||
})); | ||
} catch (error) { | ||
console.error('Fetch error:', error); | ||
throw error; | ||
} | ||
}; | ||
const tag = searchParams.get('tag') || ''; | ||
|
||
export const unfollowUser = async (userId: string): Promise<boolean> => { | ||
try { | ||
const response = await fetch(`${SERVER_URL}/api/follows/unfollow`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ userId }), | ||
}); | ||
const response = await getFollowing(req, tag); | ||
|
||
if (!response.ok) { | ||
throw new Error('API 호출에 실패했습니다'); | ||
} | ||
|
||
const data = await response.json(); | ||
|
||
if (!data.success) { | ||
throw new Error(data.errorMessage || '언팔로우에 실패했습니다'); | ||
} | ||
|
||
return true; | ||
} catch (error) { | ||
console.error('Unfollow error:', error); | ||
throw error; | ||
} | ||
}; | ||
return NextResponse.json(response); | ||
} |
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,18 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function GET(req: Request) { | ||
const response = NextResponse.json({ message: '로그아웃 완료, 쿠키 삭제됨' }); | ||
|
||
// 각각의 쿠키를 개별 Set-Cookie 헤더로 설정 | ||
response.headers.append( | ||
'Set-Cookie', | ||
'refreshToken=; path=/; domain=localhost; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax; HttpOnly', | ||
); | ||
|
||
response.headers.append( | ||
'Set-Cookie', | ||
'accessToken=; path=/; domain=localhost; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax; HttpOnly', | ||
); | ||
|
||
return response; | ||
} |
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,12 @@ | ||
import { getMember } from '@/app/service/getRequest'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function GET(req: Request) { | ||
const { searchParams } = new URL(req.url); | ||
|
||
const tag = searchParams.get('tag') || ''; | ||
|
||
const response = await getMember(req, tag); | ||
|
||
return NextResponse.json(response); | ||
} |
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,12 @@ | ||
import { getSearchMember } from '@/app/service/getRequest'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function GET(req: Request) { | ||
const { searchParams } = new URL(req.url); | ||
|
||
const tag = searchParams.get('tag') || ''; | ||
|
||
const response = await getSearchMember(req, tag); | ||
|
||
return NextResponse.json(response); | ||
} |
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,7 @@ | ||
import { getTag } from '@/app/service/getRequest'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function GET(req: Request) { | ||
const response = await getTag(req); | ||
return NextResponse.json(response); | ||
} |
Oops, something went wrong.