-
Notifications
You must be signed in to change notification settings - Fork 0
Release v0.1.0 #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release v0.1.0 #58
Changes from all commits
426d344
e9bcab8
8f072b9
2f157d6
20da864
3db20b2
585765b
4b66206
72f148f
71d7c72
f9a7765
dc9afd8
effcb19
c5be347
4c29d4c
8d93737
9364a80
420c7b3
6ae32b4
e0390b5
dd0b2d2
3bd6f5b
d3d758c
e25f7f7
b6cc590
a01b2a7
64a9ec4
0e17edf
4e81014
57f9029
c0e321e
38e8fd7
7584993
94cb995
ca70b6a
2f1ea99
5b292f5
5700500
1b5573c
a1d8cf2
291b3c1
e280297
a0392e9
54c9f37
da1ce82
8bbb2c1
0e754e9
944d864
e3bb94d
2e0944b
2678611
ee62253
40dbbaa
5243442
6c0812c
2a16b75
8585c2c
8594c59
dce9690
b86a73c
45c5434
2709e89
039403b
b80cdde
37452f4
b8f84d9
87b6617
8c5b86b
ba049f8
f50c120
b295670
f736c0c
d576640
3174240
80894e1
f55ac76
8b2bc9b
e021aa3
55ebf7a
96c12c1
067b95a
85e674f
eb927e1
ffb98f9
8500939
2a88f6d
0b37ab3
324f8c3
4144562
9742a09
2548c66
6d7d3ea
6ffba75
b16c8d7
e024658
fc59a1e
894991c
b79a118
8ac2727
f7661bd
da21284
0910751
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import {privateAxios} from '@/shared/api/axiosInstance'; | ||
| import type {TUnitFormSchema} from '../model/types'; | ||
| import type {ApiResponse} from '@/shared/model'; | ||
| import type {AllUnitsResponse, Unit} from '@/entities/course/model/types'; | ||
|
|
||
| // 강의별 전체 단원 조회 | ||
| export const getAllUnitsByCourseId = async ( | ||
| courseId: number | ||
| ): Promise<AllUnitsResponse> => { | ||
| const response = await privateAxios.get(`/courses/${courseId}/units`); | ||
| return response.data; | ||
| }; | ||
|
|
||
| // 단일 단원 조회 | ||
| export const getUnitById = async ( | ||
| unitId: number | null | ||
| ): Promise<ApiResponse<Unit>> => { | ||
| const response = await privateAxios.get(`/units/${unitId}`); | ||
| return response.data; | ||
| }; | ||
|
|
||
| // 단원 삭제 | ||
| export const deleteUnit = async ( | ||
| unitId: number | ||
| ): Promise<ApiResponse<string>> => { | ||
| const response = await privateAxios.delete(`/units/${unitId}`); | ||
| return response.data; | ||
| }; | ||
|
|
||
| // 단원 생성 | ||
| export const createUnit = async ( | ||
| courseId: number, | ||
| unit: TUnitFormSchema | ||
| ): Promise<ApiResponse<Unit>> => { | ||
| const response = await privateAxios.post(`/units/${courseId}`, unit); | ||
| return response.data; | ||
|
Comment on lines
+31
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find all unit API endpoints
echo "=== Unit API endpoints ==="
rg -nP --type=ts "privateAxios\.(get|post|put|delete)\(" src/entities/unit -C2
echo -e "\n=== Course-Unit endpoint patterns ==="
rg -nP --type=ts "/courses/\$\{[^}]+\}/units|/units/\$\{[^}]+\}" src -C2
echo -e "\n=== All unit endpoint patterns ==="
rg -nP --type=ts "/units" src -C1Repository: 2025-snowCode/snowCode-Client Length of output: 3317 생성 엔드포인트의 경로를 목록 조회와 일치시켜 주세요. 같은 파일에서 목록 조회는 제안: 🤖 Prompt for AI Agents |
||
| }; | ||
|
|
||
| // 단원 수정 | ||
| export const updateUnit = async ( | ||
| unitId: number, | ||
| unit: TUnitFormSchema | ||
| ): Promise<ApiResponse<Unit>> => { | ||
| const response = await privateAxios.put(`/units/${unitId}`, unit); | ||
| return response.data; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type {TUnitFormSchema} from '../model/types'; | ||
| import {createUnit, deleteUnit, updateUnit} from './unitApi'; | ||
|
|
||
| export const unitMutations = { | ||
| // 단원 추가 뮤테이션 옵션 | ||
| createUnit: { | ||
| mutationKey: ['createUnit'], | ||
| mutationFn: ({courseId, unit}: {courseId: number; unit: TUnitFormSchema}) => | ||
| createUnit(courseId, unit), | ||
| }, | ||
|
|
||
| // 단원 수정 뮤테이션 옵션 | ||
| updateUnit: { | ||
| mutationKey: ['updateUnit'], | ||
| mutationFn: ({unitId, unit}: {unitId: number; unit: TUnitFormSchema}) => | ||
| updateUnit(unitId, unit), | ||
| }, | ||
|
|
||
| // 단원 삭제 뮤테이션 옵션 | ||
| deleteUnit: { | ||
| mutationKey: ['deleteUnit'], | ||
| mutationFn: (unitId: number) => deleteUnit(unitId), | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullunitId가 그대로 API 경로로 들어가는 케이스를 차단해주세요.Line [16]-Line [19]에서
unitId가null이면/units/null요청이 발생합니다. 조회 실패를 런타임까지 미루지 말고 함수 레벨에서 막는 게 안전합니다.참고: TypeScript null 안전성 가이드 — https://www.typescriptlang.org/docs/handbook/2/narrowing.html
수정 제안
또는 호출부 계약상 nullable 유지가 필요하다면:
export const getUnitById = async ( unitId: number | null ): Promise<ApiResponse<Unit>> => { + if (unitId == null) { + throw new Error('unitId is required'); + } const response = await privateAxios.get(`/units/${unitId}`); return response.data; };📝 Committable suggestion
🤖 Prompt for AI Agents