Skip to content

Commit a065c9c

Browse files
authored
Merge pull request #25 from HyunsDev:develop
feat: IssueToken, CreateUser 추가 1.0.25
2 parents c064d3c + 661bda3 commit a065c9c

File tree

4 files changed

+92
-53
lines changed

4 files changed

+92
-53
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unibook-client",
3-
"version": "1.0.24",
3+
"version": "1.0.25",
44
"repository": "https://github.com/HyunsDev/unibook-client.git",
55
"author": "혀느현스 <[email protected]>",
66
"license": "Unlicense",

src/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EndpointClient } from "endpoint-client";
22
import {
33
AddBookAuthor,
44
ApproveUserOrder,
5+
IssueToken,
56
AuthOAuthGoogle,
67
CancelUserOrder,
78
CreateAndApproveCashUserOrder,
@@ -10,6 +11,7 @@ import {
1011
CreateBlockMemo,
1112
CreateBook,
1213
CreateBookmark,
14+
CreateUser,
1315
CreateUserOrder,
1416
DeleteBlockComment,
1517
DeleteBlockCommentReaction,
@@ -66,6 +68,7 @@ export class ProjectBookClient extends EndpointClient {
6668

6769
readonly ListUser = this.endpointBuilder(ListUser);
6870
readonly GetUser = this.endpointBuilder(GetUser);
71+
readonly CreateUser = this.endpointBuilder(CreateUser);
6972
readonly SearchUser = this.endpointBuilder(SearchUser);
7073
readonly UpdateUser = this.endpointBuilder(UpdateUser);
7174
readonly UpdateUserProfileImage = this.endpointBuilder(
@@ -87,6 +90,8 @@ export class ProjectBookClient extends EndpointClient {
8790

8891
readonly AuthOAuthGoogle = this.endpointBuilder(AuthOAuthGoogle);
8992

93+
readonly IssueToken = this.endpointBuilder(IssueToken);
94+
9095
readonly ListBook = this.endpointBuilder(ListBook);
9196
readonly ListAdminBook = this.endpointBuilder(ListAdminBook);
9297
readonly GetBook = this.endpointBuilder(GetBook);

src/endpoint/auth.endpoint.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,31 @@ import { Endpoint } from "endpoint-client";
55
* 구글 OAuth로 로그인
66
*/
77
export const AuthOAuthGoogle: Endpoint<AuthOAuthGoogleReq, AuthOAuthGoogleRes> =
8-
{
9-
method: "POST",
10-
path: () => `/auth/oauth/google`,
11-
bodyParams: ["code", "callbackUrl"],
12-
};
8+
{
9+
method: "POST",
10+
path: () => `/auth/oauth/google`,
11+
bodyParams: ["code", "callbackUrl"],
12+
};
1313
export type AuthOAuthGoogleReq = {
14-
code: string;
15-
callbackUrl: string;
14+
code: string;
15+
callbackUrl: string;
1616
};
1717
export type AuthOAuthGoogleRes = {
18-
token: string;
18+
token: string;
19+
};
20+
21+
/**
22+
* POST /auth/issue-token
23+
* 토큰 발급
24+
*/
25+
export const IssueToken: Endpoint<IssueTokenReq, IssueTokenRes> = {
26+
method: "POST",
27+
path: () => `/auth/issue-token`,
28+
bodyParams: ["userId"],
29+
};
30+
export type IssueTokenReq = {
31+
userId: string;
32+
};
33+
export type IssueTokenRes = {
34+
token: string;
1935
};

src/endpoint/user/endpoint.ts

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,112 +6,130 @@ import { UserObject } from "../../object/user.object";
66
* 유저를 조회합니다.
77
*/
88
export const ListUser: Endpoint<ListUserReq, ListUserRes> = {
9-
method: "GET",
10-
path: (e) => `/users`,
11-
queryParams: ["page", "take"],
9+
method: "GET",
10+
path: (e) => `/users`,
11+
queryParams: ["page", "take"],
1212
};
1313
export type ListUserReqQuery = {
14-
page?: number;
15-
take?: number;
14+
page?: number;
15+
take?: number;
1616
};
17-
export type ListUserReq = ListUserReqQuery
17+
export type ListUserReq = ListUserReqQuery;
1818
export type ListUserRes = {
19-
users: UserObject[];
20-
total: number;
19+
users: UserObject[];
20+
total: number;
2121
};
2222

2323
/**
2424
* GET /users/:userId
2525
* 유저를 조회합니다.
2626
*/
2727
export const GetUser: Endpoint<GetUserReq, GetUserRes> = {
28-
method: "GET",
29-
path: (e) => `/users/${e.userId}`,
30-
pathParams: ["userId"],
28+
method: "GET",
29+
path: (e) => `/users/${e.userId}`,
30+
pathParams: ["userId"],
3131
};
3232
export type GetUserReqPath = {
33-
userId: number | string;
33+
userId: number | string;
3434
};
3535
export type GetUserReq = GetUserReqPath;
3636
export type GetUserRes = {
37-
user: UserObject;
37+
user: UserObject;
38+
};
39+
40+
/**
41+
* POST /users
42+
* 유저를 생성합니다.
43+
*/
44+
export const CreateUser: Endpoint<CreateUserReq, CreateUserRes> = {
45+
method: "POST",
46+
path: (e) => `/users`,
47+
bodyParams: ["name", "email", "profileImage"],
48+
};
49+
export type CreateUserReq = {
50+
name: string;
51+
email: string;
52+
profileImage?: string;
53+
};
54+
export type CreateUserRes = {
55+
user: UserObject;
3856
};
3957

4058
/**
4159
* GET /users/search
4260
* 유저를 검색합니다.
4361
*/
4462
export const SearchUser: Endpoint<SearchUserReq, SearchUserRes> = {
45-
method: "GET",
46-
path: (e) => `/users/search`,
47-
queryParams: ["name", "email"],
63+
method: "GET",
64+
path: (e) => `/users/search`,
65+
queryParams: ["name", "email"],
4866
};
4967
export type SearchUserReq = {
50-
name?: string;
51-
email?: string;
68+
name?: string;
69+
email?: string;
5270
};
5371
export type SearchUserRes = {
54-
users: UserObject[];
72+
users: UserObject[];
5573
};
5674

5775
/**
5876
* PATCH /users/:userId
5977
* 유저를 수정합니다.
6078
*/
6179
export const UpdateUser: Endpoint<UpdateUserReq, UpdateUserRes> = {
62-
method: "PATCH",
63-
path: (e) => `/users/${e.userId}`,
64-
pathParams: ["userId"],
65-
bodyParams: ["name", "profileImage"],
80+
method: "PATCH",
81+
path: (e) => `/users/${e.userId}`,
82+
pathParams: ["userId"],
83+
bodyParams: ["name", "profileImage"],
6684
};
6785
export type UpdateUserReqPath = {
68-
userId: number | string;
86+
userId: number | string;
6987
};
7088
export type UpdateUserReq = UpdateUserReqPath & {
71-
name?: string;
72-
profileImage?: string;
89+
name?: string;
90+
profileImage?: string;
7391
};
7492
export type UpdateUserRes = {
75-
user: UserObject;
93+
user: UserObject;
7694
};
7795

7896
/**
7997
* PATCH /users/:userId/profile-image
8098
* 유저 프로필 이미지를 수정합니다.
8199
*/
82100
export const UpdateUserProfileImage: Endpoint<
83-
UpdateUserProfileImageReq,
84-
UpdateUserProfileImageRes
85-
> = {
86-
method: "PATCH",
87-
path: (e) => `/users/${e.userId}/profile-image`,
88-
pathParams: ["userId"],
89-
bodyParams: ["file"],
90-
headers: {
91-
"Content-Type": "multipart/form-data",
92-
}
101+
UpdateUserProfileImageReq,
102+
UpdateUserProfileImageRes
103+
> = {
104+
method: "PATCH",
105+
path: (e) => `/users/${e.userId}/profile-image`,
106+
pathParams: ["userId"],
107+
bodyParams: ["file"],
108+
headers: {
109+
"Content-Type": "multipart/form-data",
110+
},
93111
};
94112
export type UpdateUserProfileImageReqPath = {
95-
userId: number | string;
113+
userId: number | string;
96114
};
97115
export type UpdateUserProfileImageReq = UpdateUserProfileImageReqPath & {
98-
file: any;
116+
file: any;
99117
};
100118
export type UpdateUserProfileImageRes = {
101-
user: UserObject;
119+
user: UserObject;
102120
};
103121

104122
/**
105123
* DELETE /users/:userId
106124
* 유저를 삭제합니다.
107125
*/
108126
export const DeleteUser: Endpoint<DeleteUserReq, DeleteUserRes> = {
109-
method: "DELETE",
110-
path: (e) => `/users/${e.userId}`,
111-
pathParams: ["userId"],
127+
method: "DELETE",
128+
path: (e) => `/users/${e.userId}`,
129+
pathParams: ["userId"],
112130
};
113131
export type DeleteUserReqPath = {
114-
userId: number | string;
132+
userId: number | string;
115133
};
116134
export type DeleteUserReq = DeleteUserReqPath;
117135
export type DeleteUserRes = {};

0 commit comments

Comments
 (0)