Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…main-front into feature/#46/quiz
  • Loading branch information
rhehfl committed Oct 16, 2024
2 parents ac72165 + 17aae57 commit 727e7e8
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
runs-on: ubuntu-latest
steps:
# github repository에서 checkout
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# docker build 수행
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Cache docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ env.VERSION }}
Expand All @@ -36,7 +36,7 @@ jobs:
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
password: ${{ github.actor == 'bluetree7878' && secrets.bluetree7878_GHCR_TOKEN || secrets.rhehfl_ghcr_token }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
Expand All @@ -56,7 +56,7 @@ jobs:
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
password: ${{ github.actor == 'bluetree7878' && secrets.bluetree7878_GHCR_TOKEN || secrets.rhehfl_ghcr_token }}
# 3000 -> 80 포트로 수행하도록 지정
- name: Docker run
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

.env
node_modules
dist
dist-ssr
Expand Down
2 changes: 1 addition & 1 deletion src/admin/types/Quiz.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default interface Quiz {
id?: number;
part: string;
part: 'EASY' | 'NORAML' | 'HARD' | 'VERY_HARD';
sectionId: number;
title: string;
question: string;
Expand Down
6 changes: 6 additions & 0 deletions src/apis/axios/instance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import axios from 'axios';
const api = axios.create({
baseURL: import.meta.env.VITE_BASE_URL,
timeout: 5000,
});
export default api;
20 changes: 20 additions & 0 deletions src/apis/axios/intercepter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import axiosConfig from './instance';
axiosConfig.interceptors.request.use(config => {
//요청 성공 직전 호출
//헤더에 인가 토큰 부착
//로컬스토리지에 저장한다고 가정한다면
console.log('asdasd');
const accessToken: string | null = localStorage.getItem('Token');
if (accessToken !== null) {
config.headers.Authorization = `Bearer ${accessToken}`;
}

return config;
});
axiosConfig.interceptors.response.use(
//http status가 200번대인 경우 호출
response => response,
error => {
//http status가 에러 코드인경우 실행
}
);
1 change: 1 addition & 0 deletions src/apis/axios/statusCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const HTTP_STATUS = {};
15 changes: 15 additions & 0 deletions src/apis/quiz.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useQuery } from '@tanstack/react-query';
import Quiz from '../admin/types/Quiz';
import api from './axios/instance';

const QUIZ = {
getQuizzes: (sectionId: number, part: Quiz['part']) => {
return useQuery({
queryKey: ['quizzes', { sectionId, part }],
queryFn: () => api.get(`/quizzes?sectionId=${sectionId}&part=${part}`),
gcTime: 5 * 60 * 1000, // 5분
staleTime: 1 * 60 * 1000, // 1분
});
},
};
export default QUIZ;

0 comments on commit 727e7e8

Please sign in to comment.