Skip to content

Commit

Permalink
Merge pull request #25 from HyunsDev:develop
Browse files Browse the repository at this point in the history
feat: IssueToken, CreateUser 추가 1.0.25
  • Loading branch information
HyunsDev authored Mar 7, 2024
2 parents c064d3c + 661bda3 commit a065c9c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 53 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unibook-client",
"version": "1.0.24",
"version": "1.0.25",
"repository": "https://github.com/HyunsDev/unibook-client.git",
"author": "혀느현스 <[email protected]>",
"license": "Unlicense",
Expand Down
5 changes: 5 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EndpointClient } from "endpoint-client";
import {
AddBookAuthor,
ApproveUserOrder,
IssueToken,
AuthOAuthGoogle,
CancelUserOrder,
CreateAndApproveCashUserOrder,
Expand All @@ -10,6 +11,7 @@ import {
CreateBlockMemo,
CreateBook,
CreateBookmark,
CreateUser,
CreateUserOrder,
DeleteBlockComment,
DeleteBlockCommentReaction,
Expand Down Expand Up @@ -66,6 +68,7 @@ export class ProjectBookClient extends EndpointClient {

readonly ListUser = this.endpointBuilder(ListUser);
readonly GetUser = this.endpointBuilder(GetUser);
readonly CreateUser = this.endpointBuilder(CreateUser);
readonly SearchUser = this.endpointBuilder(SearchUser);
readonly UpdateUser = this.endpointBuilder(UpdateUser);
readonly UpdateUserProfileImage = this.endpointBuilder(
Expand All @@ -87,6 +90,8 @@ export class ProjectBookClient extends EndpointClient {

readonly AuthOAuthGoogle = this.endpointBuilder(AuthOAuthGoogle);

readonly IssueToken = this.endpointBuilder(IssueToken);

readonly ListBook = this.endpointBuilder(ListBook);
readonly ListAdminBook = this.endpointBuilder(ListAdminBook);
readonly GetBook = this.endpointBuilder(GetBook);
Expand Down
32 changes: 24 additions & 8 deletions src/endpoint/auth.endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,31 @@ import { Endpoint } from "endpoint-client";
* 구글 OAuth로 로그인
*/
export const AuthOAuthGoogle: Endpoint<AuthOAuthGoogleReq, AuthOAuthGoogleRes> =
{
method: "POST",
path: () => `/auth/oauth/google`,
bodyParams: ["code", "callbackUrl"],
};
{
method: "POST",
path: () => `/auth/oauth/google`,
bodyParams: ["code", "callbackUrl"],
};
export type AuthOAuthGoogleReq = {
code: string;
callbackUrl: string;
code: string;
callbackUrl: string;
};
export type AuthOAuthGoogleRes = {
token: string;
token: string;
};

/**
* POST /auth/issue-token
* 토큰 발급
*/
export const IssueToken: Endpoint<IssueTokenReq, IssueTokenRes> = {
method: "POST",
path: () => `/auth/issue-token`,
bodyParams: ["userId"],
};
export type IssueTokenReq = {
userId: string;
};
export type IssueTokenRes = {
token: string;
};
106 changes: 62 additions & 44 deletions src/endpoint/user/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,112 +6,130 @@ import { UserObject } from "../../object/user.object";
* 유저를 조회합니다.
*/
export const ListUser: Endpoint<ListUserReq, ListUserRes> = {
method: "GET",
path: (e) => `/users`,
queryParams: ["page", "take"],
method: "GET",
path: (e) => `/users`,
queryParams: ["page", "take"],
};
export type ListUserReqQuery = {
page?: number;
take?: number;
page?: number;
take?: number;
};
export type ListUserReq = ListUserReqQuery
export type ListUserReq = ListUserReqQuery;
export type ListUserRes = {
users: UserObject[];
total: number;
users: UserObject[];
total: number;
};

/**
* GET /users/:userId
* 유저를 조회합니다.
*/
export const GetUser: Endpoint<GetUserReq, GetUserRes> = {
method: "GET",
path: (e) => `/users/${e.userId}`,
pathParams: ["userId"],
method: "GET",
path: (e) => `/users/${e.userId}`,
pathParams: ["userId"],
};
export type GetUserReqPath = {
userId: number | string;
userId: number | string;
};
export type GetUserReq = GetUserReqPath;
export type GetUserRes = {
user: UserObject;
user: UserObject;
};

/**
* POST /users
* 유저를 생성합니다.
*/
export const CreateUser: Endpoint<CreateUserReq, CreateUserRes> = {
method: "POST",
path: (e) => `/users`,
bodyParams: ["name", "email", "profileImage"],
};
export type CreateUserReq = {
name: string;
email: string;
profileImage?: string;
};
export type CreateUserRes = {
user: UserObject;
};

/**
* GET /users/search
* 유저를 검색합니다.
*/
export const SearchUser: Endpoint<SearchUserReq, SearchUserRes> = {
method: "GET",
path: (e) => `/users/search`,
queryParams: ["name", "email"],
method: "GET",
path: (e) => `/users/search`,
queryParams: ["name", "email"],
};
export type SearchUserReq = {
name?: string;
email?: string;
name?: string;
email?: string;
};
export type SearchUserRes = {
users: UserObject[];
users: UserObject[];
};

/**
* PATCH /users/:userId
* 유저를 수정합니다.
*/
export const UpdateUser: Endpoint<UpdateUserReq, UpdateUserRes> = {
method: "PATCH",
path: (e) => `/users/${e.userId}`,
pathParams: ["userId"],
bodyParams: ["name", "profileImage"],
method: "PATCH",
path: (e) => `/users/${e.userId}`,
pathParams: ["userId"],
bodyParams: ["name", "profileImage"],
};
export type UpdateUserReqPath = {
userId: number | string;
userId: number | string;
};
export type UpdateUserReq = UpdateUserReqPath & {
name?: string;
profileImage?: string;
name?: string;
profileImage?: string;
};
export type UpdateUserRes = {
user: UserObject;
user: UserObject;
};

/**
* PATCH /users/:userId/profile-image
* 유저 프로필 이미지를 수정합니다.
*/
export const UpdateUserProfileImage: Endpoint<
UpdateUserProfileImageReq,
UpdateUserProfileImageRes
> = {
method: "PATCH",
path: (e) => `/users/${e.userId}/profile-image`,
pathParams: ["userId"],
bodyParams: ["file"],
headers: {
"Content-Type": "multipart/form-data",
}
UpdateUserProfileImageReq,
UpdateUserProfileImageRes
> = {
method: "PATCH",
path: (e) => `/users/${e.userId}/profile-image`,
pathParams: ["userId"],
bodyParams: ["file"],
headers: {
"Content-Type": "multipart/form-data",
},
};
export type UpdateUserProfileImageReqPath = {
userId: number | string;
userId: number | string;
};
export type UpdateUserProfileImageReq = UpdateUserProfileImageReqPath & {
file: any;
file: any;
};
export type UpdateUserProfileImageRes = {
user: UserObject;
user: UserObject;
};

/**
* DELETE /users/:userId
* 유저를 삭제합니다.
*/
export const DeleteUser: Endpoint<DeleteUserReq, DeleteUserRes> = {
method: "DELETE",
path: (e) => `/users/${e.userId}`,
pathParams: ["userId"],
method: "DELETE",
path: (e) => `/users/${e.userId}`,
pathParams: ["userId"],
};
export type DeleteUserReqPath = {
userId: number | string;
userId: number | string;
};
export type DeleteUserReq = DeleteUserReqPath;
export type DeleteUserRes = {};

0 comments on commit a065c9c

Please sign in to comment.