Skip to content

Commit

Permalink
Merge pull request #116 from wafflestudio/main
Browse files Browse the repository at this point in the history
2024 03 11 배포
  • Loading branch information
minkyu97 authored Mar 11, 2024
2 parents fc4aab6 + 8fc850b commit b59a2bc
Show file tree
Hide file tree
Showing 65 changed files with 2,143 additions and 1,146 deletions.
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_BASE_URL=https://wacruit-dev.wafflestudio.com/api
VITE_SSO_LOGIN_URL=https://sso-dev.wafflestudio.com
VITE_SSO_REDIRECT_URL=https://wacruit-dev.wafflestudio.com/sso
3 changes: 3 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_BASE_URL=https://wacruit.wafflestudio.com/api
VITE_SSO_LOGIN_URL=https://sso.wafflestudio.com
VITE_SSO_REDIRECT_URL=https://wacruit.wafflestudio.com/sso
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ module.exports = {
],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
plugins: ['react-refresh'],
plugins: ['react-refresh', 'react'],
rules: {
'react-refresh/only-export-components': 'warn',
'react/jsx-no-useless-fragment': 'error',
},
}
28 changes: 9 additions & 19 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
### 요약
- 마감 기한: YY-MM-DD
- 상태: <!-- 상태: 시작 안 함 / 진행 중 / 리뷰 필요 / 머지 필요 -->
## 요약
<!-- 1줄 요약 -->

### 태스크 URL
## 변경 내역
<!-- 가능한 상세히 작성 -->

### 체크리스트
__PR 전__
- [ ] 칸반 생성
- [ ] pre-commit 성공
- [ ] type-label 추가
## 체크리스트
- [ ] pre-commit 통과
- [ ] PR Assignees 추가
- [ ] PR Labels 추가

__머지 전__
- [ ] 칸반 옮기기
- [ ] 코멘트 리졸브
- [ ] squash & merge

### 작업 목록

### 테스트 방법 (Optional)

### 기타 질문 및 공유 사항 (Optional)
## 기타 질문 및 공유 사항 (Optional)
18 changes: 12 additions & 6 deletions .github/workflows/dev.yml → .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: Dev CICD
on:
push:
branches: main

concurrency:
group: deploy-dev
cancel-in-progress: true

jobs:
Build:
Deploy:
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -16,22 +22,22 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
run: yarn build --mode development
- name: Upload to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_DEV }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
SOURCE_DIR: "dist"
- name: Invalidate Cloudfront cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_DEV }}
DISTRIBUTION: ${{ vars.AWS_CLOUDFRONT_DISTRIBUTION }}
PATHS: "/*"
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Release 배포용 CI/CD workflow.

name: Release CICD
name: Prod CICD
on:
push:
branches: release

concurrency:
group: deploy-prod
cancel-in-progress: true

jobs:
Build:
Deploy:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -18,22 +22,22 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
run: yarn build --mode production
- name: Upload to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_RELEASE }}
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
SOURCE_DIR: "dist"
- name: Invalidate Cloudfront cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_RELEASE }}
DISTRIBUTION: ${{ vars.AWS_CLOUDFRONT_DISTRIBUTION }}
PATHS: "/*"
AWS_REGION: ${{secrets.AWS_REGION}}
AWS_REGION: ${{vars.AWS_REGION}}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^8.0.7",
"react-query": "^3.39.3",
"react-router-dom": "^6.14.0",
"rehype-katex": "^6.0.3",
"rehype-mathjax": "^4.0.3",
Expand All @@ -47,6 +46,7 @@
"@typescript-eslint/parser": "^5.59.0",
"@vitejs/plugin-react": "^4.0.0",
"eslint": "^8.38.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"husky": "^8.0.3",
Expand Down
4 changes: 4 additions & 0 deletions public/image/rightAngleBracket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import reset from "styled-reset";

const GlobalStyles = createGlobalStyle`
${reset}
html {
font-size: 9px;
}
body {
* {
font-family: Pretendard, sans-serif;
Expand Down
4 changes: 2 additions & 2 deletions src/apis/announcement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { TAnnouncement } from "../types/apiTypes";
import { getRequest } from "./utility";

export const getAllAnnouncements = () =>
getRequest<{ items: TAnnouncement[] }>("/announcements", {}, false).then(
getRequest<{ items: TAnnouncement[] }>("/v1/announcements", {}, false).then(
(res) => res.items.reverse(),
);

export const getPinnedAnnouncements = () =>
getRequest<{ items: TAnnouncement[] }>(
"/announcements/pinned",
"/v1/announcements/pinned",
{},
false,
).then((res) => res.items);
8 changes: 4 additions & 4 deletions src/apis/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Cookies from "js-cookie";
import { ssoLoginURL, ssoRedirectURI } from "./environment";
import { SSO_LOGIN_URL, SSO_REDIRECT_URL } from "./environment";
import { getRequest } from "./utility";

const SSO_COOKIE_KEY = "waffle.access-token";
Expand All @@ -15,15 +15,15 @@ export const getSsoToken = (): string | null => {
};

export const deleteSsoToken = () => {
Cookies.remove(SSO_COOKIE_KEY, { path:"/", domain:".wafflestudio.com" });
Cookies.remove(SSO_COOKIE_KEY, { path: "/", domain: ".wafflestudio.com" });
};

export const tryLogin = (recruit_id: number | "home") => {
location.href = `${ssoLoginURL}${ssoRedirectURI(recruit_id)}`;
location.href = `${SSO_LOGIN_URL}/?redirect_uri=${SSO_REDIRECT_URL}/${recruit_id}`;
};

export const checkAuth = (): Promise<"invalid" | "valid" | "need_register"> =>
getRequest<{ signup: boolean }>("/users/check").then(
getRequest<{ signup: boolean }>("/v1/users/check").then(
(res) => (res.signup ? ("valid" as const) : ("need_register" as const)),
() => Promise.resolve("invalid" as const),
);
22 changes: 5 additions & 17 deletions src/apis/environment.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
/*
export const baseURL =
import.meta.env.VITE_API_TYPE === "MSW"
? ""
: "https://wacruit-dev.wafflestudio.com/api/v1";
export const BASE_URL =
import.meta.env.VITE_API_TYPE === "MSW" ? "" : import.meta.env.VITE_BASE_URL;

export const ssoLoginURL =
export const SSO_LOGIN_URL =
import.meta.env.VITE_API_TYPE === "MSW"
? ""
: "https://sso-dev.wafflestudio.com/?redirect_uri=";
export const ssoRedirectURI = (recruitId: number | "home") =>
`https://wacruit-dev.wafflestudio.com/sso/${recruitId}`;
*/

export const baseURL = "https://wacruit.wafflestudio.com/api/v1";

export const ssoLoginURL = "https://sso.wafflestudio.com/?redirect_uri=";
: import.meta.env.VITE_SSO_LOGIN_URL;

export const ssoRedirectURI = (recruitId: number | "home") =>
`https://wacruit.wafflestudio.com/sso/${recruitId}`;
export const SSO_REDIRECT_URL = import.meta.env.VITE_SSO_REDIRECT_URL;
76 changes: 58 additions & 18 deletions src/apis/portfolio.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,79 @@
import { PortfolioFile, PortfolioLink } from "../types/apiTypes";
import { deleteRequest, getRequest, postRequest, putRequest } from "./utility";

export const getPortfolioFiles = () =>
getRequest<{ items: PortfolioFile[] }>(`/portfolios/file`);
export const getPortfolioFiles = (recruiting_id: number) =>
getRequest<{ items: PortfolioFile[] }>(
`/v2/portfolios/file?recruiting_id=${recruiting_id}`,
);

export const getPortfolioLinks = () =>
getRequest<{ items: PortfolioLink[] }>(`/portfolios/url`);
export const getPortfolioLinks = (recruiting_id: number) =>
getRequest<{ items: PortfolioLink[] }>(
`/v2/portfolios/url?recruiting_id=${recruiting_id}`,
);

export const postPortfolioLink = (url: string) =>
postRequest(`/portfolios/url`, {
export const postPortfolioLink = (url: string, recruiting_id: number) =>
postRequest(`/v2/portfolios/url`, {
url,
recruiting_id,
});

export const putPortfolioLink = (linkId: number, url: string) =>
putRequest(`/portfolios/url/${linkId}`, {
export const putPortfolioLink = (
linkId: number,
url: string,
recruiting_id: number,
) =>
putRequest(`/v2/portfolios/url/${linkId}`, {
url,
recruiting_id,
});

export const deletePortfolioLink = (linkId: number) =>
deleteRequest(`/portfolios/url/${linkId}`, {});
deleteRequest(`/v2/portfolios/url/${linkId}`, {});

export const postPortfolioFile = (fileName: string) =>
getRequest<{ presigned_url: string; fields: object }>(
`/portfolios/file/url/upload?file_name=${fileName}`,
);
export const downloadPortfolioFile = (fileName: string) =>
export const postPortfolioFile = (targetFile: File, recruiting_id: number) =>
postRequest<{
presigned_url: string;
fields: object;
portfolio_file_id: number;
}>(`/v2/portfolios/file/url/upload`, {
recruiting_id,
file_name: targetFile.name,
})
.then(({ presigned_url, fields, portfolio_file_id }) =>
uploadPortfolioFileToS3(presigned_url, fields, targetFile).then(() =>
Promise.resolve(portfolio_file_id),
),
)
.then((id) =>
notifyOnPortfolioFileUpload(id).then(() => Promise.resolve(id)),
);

export const downloadPortfolioFile = (id: number) =>
getRequest<{
object_name: string;
presigned_url: string;
fields: object | null;
}>(`/portfolios/file/url/download?file_name=${fileName}`);
export const deletePortfolioFile = (fileName: string) =>
deleteRequest(`/portfolios/file/delete?file_name=${fileName}`, {});
}>(`/v2/portfolios/file/url/download/${id}`).then(
({ object_name, presigned_url }) => {
/**
* @TODO 정말 이 방법 밖에는 없는가?
*/
const link = document.createElement("a");
link.href = presigned_url;
link.setAttribute("download", `${object_name}`);
document.body.appendChild(link);
link.click();
link.parentNode?.removeChild(link);
},
);

export const deletePortfolioFile = (id: number) =>
deleteRequest(`/v2/portfolios/file/delete/${id}`, {});

const notifyOnPortfolioFileUpload = (id: number) =>
getRequest(`/v2/portfolios/file/url/check-upload-completed/${id}`);

export const uploadPortfolioFileToS3 = (
const uploadPortfolioFileToS3 = (
presignedUrl: string,
data: object,
file: File,
Expand Down
4 changes: 2 additions & 2 deletions src/apis/problem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { getRequest, sseRequest } from "./utility";

export const getProblemById = (problem_id: number) =>
getRequest<Problem>(`/problems/${problem_id}`);
getRequest<Problem>(`/v1/problems/${problem_id}`);

export const postProblemSubmission = (
problemSubmission: ProblemSubmissionRequest,
Expand All @@ -16,7 +16,7 @@ export const postProblemSubmission = (
| { type: "message"; data: { items: ProblemSubmissionResult[] } }
| { type: "error"; data: { detail: string } }
>(
"/problems/submission",
"/v1/problems/submission",
problemSubmission,
{}, // headers
true, // authorized
Expand Down
12 changes: 8 additions & 4 deletions src/apis/recruiting.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Recruiting, RecruitingSummary } from "../types/apiTypes";
import {
Recruiting,
RecruitingResult,
RecruitingSummary,
} from "../types/apiTypes";
import { getRequest } from "./utility";

export const getAllRecruitings = () =>
getRequest<{ items: RecruitingSummary[] }>(`/recruitings`, {}, false);
getRequest<{ items: RecruitingSummary[] }>(`/v1/recruitings`, {}, false);

export const getRecruitingById = (id: Recruiting["id"]) =>
getRequest<Recruiting>(`/recruitings/${id}`);
getRequest<Recruiting>(`/v1/recruitings/${id}`);

export const getRecruitingResult = (id: Recruiting["id"]) =>
getRequest<{ status: number }>(`/recruitings/${id}/result`);
getRequest<RecruitingResult>(`/v1/recruitings/${id}/result`);
Loading

0 comments on commit b59a2bc

Please sign in to comment.