diff --git a/.eslintrc.json b/frontend/.eslintrc.json similarity index 100% rename from .eslintrc.json rename to frontend/.eslintrc.json diff --git a/.gitignore b/frontend/.gitignore similarity index 100% rename from .gitignore rename to frontend/.gitignore diff --git a/.prettierrc b/frontend/.prettierrc similarity index 100% rename from .prettierrc rename to frontend/.prettierrc diff --git a/README.md b/frontend/README.md similarity index 100% rename from README.md rename to frontend/README.md diff --git a/frontend/app/axios.ts b/frontend/app/axios.ts new file mode 100644 index 0000000..591adcb --- /dev/null +++ b/frontend/app/axios.ts @@ -0,0 +1,76 @@ +'use client' +// :: Production Axios Instance +import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios' + +// :: create Instance +const baseConfig = { + baseURL: process.env.NEXT_PUBLIC_BASE_URL, + timeout: 10 * 1000, +} + +const instance = axios.create(baseConfig) +const tokenInstance = axios.create(baseConfig) +const multipartInstance = axios.create(baseConfig) +const tokenMultipartInstance = axios.create(baseConfig) + +// :: interceptor setting +// 1. request +// - 요청이 전달되기 전에 작업 수행 +const requestPrev = (config: InternalAxiosRequestConfig): InternalAxiosRequestConfig => { + config.headers['Content-Type'] = 'application/json' + config.baseURL = process.env.NEXT_PUBLIC_BASE_URL + return config +} +const tokenReqPrev = (config: InternalAxiosRequestConfig): InternalAxiosRequestConfig => { + config.headers['Content-Type'] = 'application/json' + config.baseURL = process.env.NEXT_PUBLIC_BASE_URL + config.withCredentials = true + + return config +} +const multipartReqPrev = (config: InternalAxiosRequestConfig): InternalAxiosRequestConfig => { + config.headers['Content-Type'] = 'multipart/form-data' + config.baseURL = process.env.NEXT_PUBLIC_BASE_URL + return config +} +const tokenMultipartReqPrev = (config: InternalAxiosRequestConfig): InternalAxiosRequestConfig => { + config.headers['Content-Type'] = 'multipart/form-data' + config.baseURL = process.env.NEXT_PUBLIC_BASE_URL + config.withCredentials = true + + return config +} +// 요청 오류가 있는 작업 수행 +const requestError = (error: unknown): Promise => { + return Promise.reject(error) +} + +// 2. response +// - 2xx 범위에 있는 상태 코드는 이 함수를 트리거 합니다. +// - 응답 데이터가 있는 작업 수행 +const resolveResponse = (response: AxiosResponse): AxiosResponse => response +// - 2xx 외의 범위에 있는 상태 코드는 이 함수를 트리거 합니다. +// - 응답 오류가 있는 작업 수행 +const responseError = (error: AxiosError): Promise => { + console.log(error) + return Promise.reject(error) +} + +instance.interceptors.request.use(requestPrev, requestError) +instance.interceptors.response.use(resolveResponse, responseError) + +multipartInstance.interceptors.request.use(multipartReqPrev, requestError) +multipartInstance.interceptors.response.use(resolveResponse, responseError) + +tokenInstance.interceptors.request.use(tokenReqPrev, requestError) +tokenInstance.interceptors.response.use(resolveResponse, responseError) + +tokenMultipartInstance.interceptors.request.use(tokenMultipartReqPrev, requestError) +tokenMultipartInstance.interceptors.response.use(resolveResponse, responseError) + +// :: axios Error 여부 판단 +const isAxiosError = (err: unknown | AxiosError): err is AxiosError => { + return axios.isAxiosError(err) +} + +export { instance, tokenInstance, multipartInstance, tokenMultipartInstance, isAxiosError } diff --git a/app/favicon.ico b/frontend/app/favicon.ico similarity index 100% rename from app/favicon.ico rename to frontend/app/favicon.ico diff --git a/app/globals.css b/frontend/app/globals.css similarity index 100% rename from app/globals.css rename to frontend/app/globals.css diff --git a/app/layout.tsx b/frontend/app/layout.tsx similarity index 100% rename from app/layout.tsx rename to frontend/app/layout.tsx diff --git a/app/lib/action.ts b/frontend/app/lib/action.ts similarity index 100% rename from app/lib/action.ts rename to frontend/app/lib/action.ts diff --git a/app/lib/api.ts b/frontend/app/lib/api.ts similarity index 100% rename from app/lib/api.ts rename to frontend/app/lib/api.ts diff --git a/app/lib/hooks/directory_manual.txt b/frontend/app/lib/hooks/directory_manual.txt similarity index 100% rename from app/lib/hooks/directory_manual.txt rename to frontend/app/lib/hooks/directory_manual.txt diff --git a/frontend/.gitkeep b/frontend/app/lib/hooks/socket.ts similarity index 100% rename from frontend/.gitkeep rename to frontend/app/lib/hooks/socket.ts diff --git a/app/lib/hooks/useReactQuery.tsx b/frontend/app/lib/hooks/useReactQuery.tsx similarity index 100% rename from app/lib/hooks/useReactQuery.tsx rename to frontend/app/lib/hooks/useReactQuery.tsx diff --git a/app/lib/query.ts b/frontend/app/lib/query.ts similarity index 100% rename from app/lib/query.ts rename to frontend/app/lib/query.ts diff --git a/app/lib/services/directory_manual.txt b/frontend/app/lib/services/directory_manual.txt similarity index 100% rename from app/lib/services/directory_manual.txt rename to frontend/app/lib/services/directory_manual.txt diff --git a/app/lib/store.ts b/frontend/app/lib/store.ts similarity index 100% rename from app/lib/store.ts rename to frontend/app/lib/store.ts diff --git a/app/lib/type.d.ts b/frontend/app/lib/type.d.ts similarity index 100% rename from app/lib/type.d.ts rename to frontend/app/lib/type.d.ts diff --git a/app/lib/util.ts b/frontend/app/lib/util.ts similarity index 100% rename from app/lib/util.ts rename to frontend/app/lib/util.ts diff --git a/app/lib/utilHook.ts b/frontend/app/lib/utilHook.ts similarity index 100% rename from app/lib/utilHook.ts rename to frontend/app/lib/utilHook.ts diff --git a/frontend/app/lobby/lib/hooks/.gitkeep b/frontend/app/lobby/lib/hooks/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/app/lobby/lib/services/.gitkeep b/frontend/app/lobby/lib/services/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/app/lobby/page.tsx b/frontend/app/lobby/page.tsx new file mode 100644 index 0000000..07fa18d --- /dev/null +++ b/frontend/app/lobby/page.tsx @@ -0,0 +1,7 @@ +import React from 'react' + +const Lobby = () => { + return
Lobby
+} + +export default Lobby diff --git a/frontend/app/lobby/ui/.gitkeep b/frontend/app/lobby/ui/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/page.tsx b/frontend/app/page.tsx similarity index 100% rename from app/page.tsx rename to frontend/app/page.tsx diff --git a/app/ui/directory_manual.txt b/frontend/app/ui/directory_manual.txt similarity index 100% rename from app/ui/directory_manual.txt rename to frontend/app/ui/directory_manual.txt diff --git a/next.config.mjs b/frontend/next.config.mjs similarity index 100% rename from next.config.mjs rename to frontend/next.config.mjs diff --git a/package-lock.json b/frontend/package-lock.json similarity index 100% rename from package-lock.json rename to frontend/package-lock.json diff --git a/package.json b/frontend/package.json similarity index 100% rename from package.json rename to frontend/package.json diff --git a/postcss.config.mjs b/frontend/postcss.config.mjs similarity index 100% rename from postcss.config.mjs rename to frontend/postcss.config.mjs diff --git a/public/next.svg b/frontend/public/next.svg similarity index 100% rename from public/next.svg rename to frontend/public/next.svg diff --git a/public/vercel.svg b/frontend/public/vercel.svg similarity index 100% rename from public/vercel.svg rename to frontend/public/vercel.svg diff --git a/tailwind.config.ts b/frontend/tailwind.config.ts similarity index 100% rename from tailwind.config.ts rename to frontend/tailwind.config.ts diff --git a/tsconfig.json b/frontend/tsconfig.json similarity index 100% rename from tsconfig.json rename to frontend/tsconfig.json