-
Notifications
You must be signed in to change notification settings - Fork 4
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 #247 from boostcampwm-2024/dev-fe
[MERGE] dev-fe -> dev 로 병합
- Loading branch information
Showing
163 changed files
with
6,170 additions
and
14,675 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,56 @@ | ||
name: Build and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- prod-fe | ||
|
||
jobs: | ||
build: | ||
name: Build, Test, and Push Docker Image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies with Yarn | ||
run: yarn install | ||
|
||
- name: Build only backend package with Yarn | ||
run: yarn build:fe | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
run: | | ||
docker compose -f fe.build.yaml build --no-cache | ||
docker compose -f fe.build.yaml push | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
|
||
- name: Execute deployment script on remote server | ||
env: | ||
SSH_PEM_KEY: ${{ secrets.SSH_PEM_KEY }} | ||
SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | ||
SSH_PORT: ${{ secrets.SSH_PORT }} | ||
|
||
run: | | ||
mkdir -p ~/.ssh | ||
echo "$SSH_PEM_KEY" > ~/.ssh/SSH_PEM_KEY.pem | ||
chmod 600 ~/.ssh/SSH_PEM_KEY.pem | ||
ssh -p $SSH_PORT -i ~/.ssh/SSH_PEM_KEY.pem -o StrictHostKeyChecking=no [email protected] 'cd prod && bash prod_fe.sh' | ||
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,14 @@ | ||
# docker-compose.yml | ||
version: '3.8' | ||
|
||
services: | ||
nginx: | ||
build: | ||
context: nginx | ||
dockerfile: dockerfile | ||
image: liboost/nginx:latest | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
- "8000:8000" | ||
- "1935:1935" |
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
Binary file not shown.
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 { fetchInstance } from '.'; | ||
|
||
export type BroadcastStatusResponse = { | ||
state: boolean; | ||
}; | ||
|
||
export const fetchBroadcastStatus = async (sessionKey: string): Promise<BroadcastStatusResponse> => { | ||
const response = await fetchInstance().get<BroadcastStatusResponse>('/host/state', { | ||
params: { | ||
sessionKey | ||
} | ||
}); | ||
|
||
return { | ||
state: response.data.state | ||
}; | ||
}; |
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 { AxiosResponse } from 'axios'; | ||
import { fetchInstance } from '.'; | ||
import { ClientLive } from '@type/live'; | ||
|
||
type ClientLiveResponse = { | ||
info: ClientLive; | ||
}; | ||
|
||
export const fetchLive = async ({ liveId }: { liveId: string }): Promise<ClientLive> => { | ||
const response: AxiosResponse<ClientLiveResponse> = await fetchInstance().get('/streams/live', { | ||
params: { | ||
liveId | ||
} | ||
}); | ||
|
||
return response.data.info; | ||
}; |
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,13 @@ | ||
import { AxiosResponse } from 'axios'; | ||
import { fetchInstance } from '.'; | ||
import { MainLive } from '@type/live'; | ||
|
||
type MainLiveResponse = { | ||
info: MainLive[]; | ||
}; | ||
|
||
export const fetchMainLive = async (): Promise<MainLive[]> => { | ||
const response: AxiosResponse<MainLiveResponse> = await fetchInstance().get('/streams/random'); | ||
|
||
return response.data.info; | ||
}; |
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,9 @@ | ||
import { AxiosResponse } from 'axios'; | ||
import { fetchInstance } from '.'; | ||
import { RecentLiveResponse } from '@type/live'; | ||
|
||
export const fetchRecentLive = async (): Promise<RecentLiveResponse> => { | ||
const response: AxiosResponse = await fetchInstance().get('/streams/latest'); | ||
|
||
return response.data; | ||
}; |
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,9 @@ | ||
import { AxiosResponse } from 'axios'; | ||
import { fetchInstance } from '.'; | ||
import { RecentReplayResponse } from '@type/replay'; | ||
|
||
export const fetchRecentReplay = async (): Promise<RecentReplayResponse> => { | ||
const response: AxiosResponse = await fetchInstance().get('/replay/latest'); | ||
|
||
return response.data; | ||
}; |
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 { AxiosResponse } from 'axios'; | ||
import { fetchInstance } from '.'; | ||
import { ReplayStream } from '@type/replay'; | ||
|
||
type ReplayStreamResponse = { | ||
info: ReplayStream; | ||
}; | ||
|
||
export const fetchReplay = async ({ videoId }: { videoId: string }): Promise<ReplayStream> => { | ||
const response: AxiosResponse<ReplayStreamResponse> = await fetchInstance().get('/replay/video', { | ||
params: { | ||
videoId | ||
} | ||
}); | ||
|
||
return response.data.info; | ||
}; |
16 changes: 9 additions & 7 deletions
16
frontend/src/apis/host/fetchStreamKey.ts → frontend/src/apis/fetchStreamKey.ts
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,14 +1,16 @@ | ||
import { AxiosResponse } from 'axios'; | ||
import { BASE_URL, fetchInstance } from '..'; | ||
|
||
type StreamKeyResponse = { | ||
'stream-key': string; | ||
'session-key': string; | ||
}; | ||
import { fetchInstance } from '.'; | ||
|
||
type NanoId = string; | ||
|
||
export type StreamKeyResponse = { | ||
streamKey: string; | ||
sessionKey: string; | ||
}; | ||
|
||
export const fetchStreamKey = async (userId: NanoId): Promise<StreamKeyResponse> => { | ||
const response: AxiosResponse<StreamKeyResponse> = await fetchInstance().post(`${BASE_URL}/host/key`, { userId }); | ||
const response: AxiosResponse<StreamKeyResponse> = await fetchInstance().post('/host/key', { | ||
userId | ||
}); | ||
return response.data; | ||
}; |
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 { useQuery } from '@tanstack/react-query'; | ||
|
||
import { fetchLive } from '@apis/fetchLive'; | ||
import { ClientLive } from '@type/live'; | ||
|
||
export const useClientLive = ({ liveId }: { liveId: string }) => { | ||
return useQuery<ClientLive, Error>({ | ||
queryKey: ['clientLive'], | ||
queryFn: () => fetchLive({ liveId: liveId }), | ||
refetchOnWindowFocus: false | ||
}); | ||
}; |
15 changes: 15 additions & 0 deletions
15
frontend/src/apis/queries/host/useBroadcastStatusPolling.ts
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,15 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { fetchBroadcastStatus } from '@apis/fetchBroadcastStatus'; | ||
|
||
export const useBroadcastStatusPolling = (sessionKey: string, pollingInterVal = 10000) => { | ||
return useQuery({ | ||
queryKey: ['broadcastState', sessionKey], | ||
queryFn: () => fetchBroadcastStatus(sessionKey), | ||
refetchInterval: pollingInterVal, | ||
refetchIntervalInBackground: true, | ||
refetchOnWindowFocus: true, | ||
retry: 3, | ||
initialData: { state: false }, | ||
select: (data) => data.state | ||
}); | ||
}; |
7 changes: 1 addition & 6 deletions
7
...end/src/queries/host/useFetchStreamKey.ts → ...rc/apis/queries/host/useFetchStreamKey.ts
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,20 @@ | ||
import { updateHost } from '@apis/updateHost'; | ||
import { useMutation, UseMutationResult } from '@tanstack/react-query'; | ||
import { HostInfo } from '@type/hostInfo'; | ||
|
||
type Params = { | ||
onSuccess?: (data: HostInfo) => void; | ||
onError?: (error: Error) => void; | ||
}; | ||
|
||
export default function useUpdateHost({ onSuccess, onError }: Params = {}): UseMutationResult< | ||
HostInfo, | ||
Error, | ||
HostInfo | ||
> { | ||
return useMutation({ | ||
mutationFn: (hostInfo: HostInfo) => updateHost(hostInfo), | ||
onSuccess, | ||
onError | ||
}); | ||
} |
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 { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
import { fetchMainLive } from '@apis/fetchMainLive'; | ||
import { MainLive } from '@type/live'; | ||
|
||
export const useMainLive = () => { | ||
return useSuspenseQuery<MainLive[], Error>({ | ||
queryKey: ['mainLive'], | ||
queryFn: fetchMainLive, | ||
refetchOnWindowFocus: false, | ||
}); | ||
}; |
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,13 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { fetchRecentLive } from '@apis/fetchRecentLive'; | ||
import { RecentLiveResponse } from '@type/live'; | ||
|
||
export const useRecentLive = () => { | ||
return useQuery<RecentLiveResponse, Error>({ | ||
queryKey: ['recentLive'], | ||
queryFn: fetchRecentLive, | ||
refetchOnWindowFocus: false, | ||
initialData: { info: [], appendInfo: [] } | ||
}); | ||
}; |
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,13 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { fetchRecentReplay } from '@apis/fetchRecentReplay'; | ||
import { RecentReplayResponse } from '@type/replay'; | ||
|
||
export const useRecentReplay = () => { | ||
return useQuery<RecentReplayResponse, Error>({ | ||
queryKey: ['recentReplay'], | ||
queryFn: fetchRecentReplay, | ||
refetchOnWindowFocus: false, | ||
initialData: { info: [], appendInfo: [] } | ||
}); | ||
}; |
Oops, something went wrong.