dn-react-router-toolkit 0.1.12 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/auth/apple_auth.d.mts +38 -0
  2. package/dist/auth/apple_auth.d.ts +38 -0
  3. package/dist/{auth-kit → auth}/apple_auth.js +31 -18
  4. package/dist/auth/apple_auth.mjs +63 -0
  5. package/dist/{auth-kit/repository.d.mts → auth/auth_repository.d.mts} +6 -9
  6. package/dist/{auth-kit/repository.d.ts → auth/auth_repository.d.ts} +6 -9
  7. package/dist/{file-kit/repository.js → auth/auth_repository.js} +3 -3
  8. package/dist/{auth-kit → auth}/auth_service.d.mts +11 -22
  9. package/dist/{auth-kit → auth}/auth_service.d.ts +11 -22
  10. package/dist/{auth-kit → auth}/auth_service.js +23 -76
  11. package/dist/{auth-kit → auth}/auth_service.mjs +23 -76
  12. package/dist/auth/client/google_login_button.d.mts +7 -0
  13. package/dist/auth/client/google_login_button.d.ts +7 -0
  14. package/dist/{auth-kit → auth}/client/google_login_button.js +24 -19
  15. package/dist/auth/client/google_login_button.mjs +37 -0
  16. package/dist/auth/client/provider.d.mts +23 -0
  17. package/dist/auth/client/provider.d.ts +23 -0
  18. package/dist/auth/client/provider.js +137 -0
  19. package/dist/auth/client/provider.mjs +101 -0
  20. package/dist/{auth-kit → auth}/client/redirect_page.js +1 -1
  21. package/dist/{auth-kit → auth}/client/redirect_page.mjs +1 -1
  22. package/dist/auth/google_auth.d.mts +33 -0
  23. package/dist/auth/google_auth.d.ts +33 -0
  24. package/dist/{auth-kit → auth}/google_auth.js +23 -32
  25. package/dist/{auth-kit → auth}/google_auth.mjs +22 -31
  26. package/dist/auth/handlers/find_auth.d.mts +13 -0
  27. package/dist/auth/handlers/find_auth.d.ts +13 -0
  28. package/dist/{route/api/auth/route.js → auth/handlers/find_auth.js} +10 -10
  29. package/dist/{route/api/auth/route.mjs → auth/handlers/find_auth.mjs} +5 -5
  30. package/dist/auth/handlers/login.d.mts +13 -0
  31. package/dist/auth/handlers/login.d.ts +13 -0
  32. package/dist/{route/api/auth/login/route.js → auth/handlers/login.js} +17 -17
  33. package/dist/{route/api/auth/login/route.mjs → auth/handlers/login.mjs} +12 -12
  34. package/dist/auth/handlers/login_with_thirdparty.d.mts +15 -0
  35. package/dist/auth/handlers/login_with_thirdparty.d.ts +15 -0
  36. package/dist/{route/api/auth/login/[provider]/route.js → auth/handlers/login_with_thirdparty.js} +12 -27
  37. package/dist/{route/api/auth/login/[provider]/route.mjs → auth/handlers/login_with_thirdparty.mjs} +7 -22
  38. package/dist/auth/handlers/logout.d.mts +13 -0
  39. package/dist/auth/handlers/logout.d.ts +13 -0
  40. package/dist/{route/api/auth/logout/route.js → auth/handlers/logout.js} +15 -11
  41. package/dist/{route/api/auth/logout/route.mjs → auth/handlers/logout.mjs} +11 -7
  42. package/dist/auth/handlers/refresh.d.mts +13 -0
  43. package/dist/auth/handlers/refresh.d.ts +13 -0
  44. package/dist/{route/api/auth/refresh/route.js → auth/handlers/refresh.js} +12 -12
  45. package/dist/{route/api/auth/refresh/route.mjs → auth/handlers/refresh.mjs} +7 -7
  46. package/dist/auth/handlers/signup.d.mts +15 -0
  47. package/dist/auth/handlers/signup.d.ts +15 -0
  48. package/dist/auth/handlers/signup.js +135 -0
  49. package/dist/auth/handlers/signup.mjs +100 -0
  50. package/dist/auth/handlers/signup_with_thirdparty.d.mts +17 -0
  51. package/dist/auth/handlers/signup_with_thirdparty.d.ts +17 -0
  52. package/dist/auth/handlers/signup_with_thirdparty.js +123 -0
  53. package/dist/auth/handlers/signup_with_thirdparty.mjs +98 -0
  54. package/dist/auth/handlers/thirdparty_auth_callback.d.mts +16 -0
  55. package/dist/auth/handlers/thirdparty_auth_callback.d.ts +16 -0
  56. package/dist/{route/auth/callback/[provider]/route.js → auth/handlers/thirdparty_auth_callback.js} +54 -45
  57. package/dist/{route/auth/callback/[provider]/route.mjs → auth/handlers/thirdparty_auth_callback.mjs} +49 -40
  58. package/dist/{auth-kit/jwt.d.mts → auth/jwt_manager.d.mts} +11 -1
  59. package/dist/{auth-kit/jwt.d.ts → auth/jwt_manager.d.ts} +11 -1
  60. package/dist/{auth-kit/jwt.js → auth/jwt_manager.js} +25 -11
  61. package/dist/{auth-kit/jwt.mjs → auth/jwt_manager.mjs} +22 -8
  62. package/dist/auth/kakao_auth.d.mts +27 -0
  63. package/dist/auth/kakao_auth.d.ts +27 -0
  64. package/dist/auth/kakao_auth.js +56 -0
  65. package/dist/auth/kakao_auth.mjs +31 -0
  66. package/dist/auth/thirdparty_auth.d.mts +41 -0
  67. package/dist/auth/thirdparty_auth.d.ts +41 -0
  68. package/dist/{auth-kit/kakao_auth.js → auth/thirdparty_auth.js} +31 -33
  69. package/dist/{auth-kit/kakao_auth.mjs → auth/thirdparty_auth.mjs} +26 -28
  70. package/dist/{auth-kit → auth}/with_auth.d.mts +5 -6
  71. package/dist/{auth-kit → auth}/with_auth.d.ts +5 -6
  72. package/dist/{auth-kit → auth}/with_auth.js +26 -10
  73. package/dist/auth/with_auth.mjs +63 -0
  74. package/dist/date.d.mts +2 -0
  75. package/dist/date.d.ts +2 -0
  76. package/dist/date.js +4 -2
  77. package/dist/date.mjs +2 -1
  78. package/dist/{file-kit → file}/cdn.js +1 -1
  79. package/dist/{file-kit → file}/cdn.mjs +1 -1
  80. package/dist/{file-kit → file}/client/drop_file_input.js +3 -3
  81. package/dist/{file-kit → file}/client/drop_file_input.mjs +3 -3
  82. package/dist/{file-kit → file}/client/file_upload_button.js +1 -1
  83. package/dist/{file-kit → file}/client/file_upload_button.mjs +1 -1
  84. package/dist/{file-kit → file}/client/file_uploader.js +3 -3
  85. package/dist/{file-kit → file}/client/file_uploader.mjs +2 -2
  86. package/dist/{file-kit → file}/client/format_size.js +1 -1
  87. package/dist/{file-kit → file}/client/format_size.mjs +1 -1
  88. package/dist/{file-kit → file}/client/metadata.js +1 -1
  89. package/dist/{file-kit → file}/client/metadata.mjs +1 -1
  90. package/dist/{file-kit/repository.d.mts → file/file_repository.d.mts} +4 -4
  91. package/dist/{file-kit/repository.d.ts → file/file_repository.d.ts} +4 -4
  92. package/dist/{auth-kit/repository.js → file/file_repository.js} +3 -3
  93. package/dist/file/file_service.d.mts +32 -0
  94. package/dist/file/file_service.d.ts +32 -0
  95. package/dist/{file-kit → file}/file_service.js +27 -21
  96. package/dist/file/file_service.mjs +41 -0
  97. package/dist/file/handlers/delete_file.d.mts +17 -0
  98. package/dist/file/handlers/delete_file.d.ts +17 -0
  99. package/dist/{route/api/files/[fileId]/route.js → file/handlers/delete_file.js} +15 -15
  100. package/dist/{route/api/files/[fileId]/route.mjs → file/handlers/delete_file.mjs} +10 -10
  101. package/dist/file/handlers/upload_file.d.mts +16 -0
  102. package/dist/file/handlers/upload_file.d.ts +16 -0
  103. package/dist/{route/api/files/route.js → file/handlers/upload_file.js} +13 -13
  104. package/dist/{route/api/files/route.mjs → file/handlers/upload_file.mjs} +8 -8
  105. package/dist/{file-kit → file}/object_storage.d.mts +3 -1
  106. package/dist/{file-kit → file}/object_storage.d.ts +3 -1
  107. package/dist/{file-kit → file}/object_storage.js +2 -2
  108. package/dist/{file-kit → file}/object_storage.mjs +2 -2
  109. package/dist/{file-kit → file}/responsive_image.d.mts +4 -4
  110. package/dist/{file-kit → file}/responsive_image.d.ts +4 -4
  111. package/dist/{file-kit → file}/responsive_image.js +18 -9
  112. package/dist/{file-kit → file}/responsive_image.mjs +18 -9
  113. package/dist/{http-kit → http}/index.js +5 -5
  114. package/dist/{http-kit → http}/index.mjs +1 -1
  115. package/dist/{http-kit → http}/response.js +1 -1
  116. package/dist/{http-kit → http}/response.mjs +1 -1
  117. package/dist/index.d.mts +1 -0
  118. package/dist/index.d.ts +1 -0
  119. package/dist/index.js +2 -0
  120. package/dist/index.mjs +1 -0
  121. package/dist/route/api.d.mts +15 -25
  122. package/dist/route/api.d.ts +15 -25
  123. package/dist/route/api.js +325 -178
  124. package/dist/route/api.mjs +314 -177
  125. package/dist/{seo-kit → seo}/seo.js +1 -1
  126. package/dist/{seo-kit → seo}/seo.mjs +1 -1
  127. package/package.json +74 -74
  128. package/dist/auth-kit/apple_auth.d.mts +0 -24
  129. package/dist/auth-kit/apple_auth.d.ts +0 -24
  130. package/dist/auth-kit/apple_auth.mjs +0 -50
  131. package/dist/auth-kit/client/google_login_button.d.mts +0 -9
  132. package/dist/auth-kit/client/google_login_button.d.ts +0 -9
  133. package/dist/auth-kit/client/google_login_button.mjs +0 -32
  134. package/dist/auth-kit/client/logout.d.mts +0 -3
  135. package/dist/auth-kit/client/logout.d.ts +0 -3
  136. package/dist/auth-kit/client/logout.js +0 -49
  137. package/dist/auth-kit/client/logout.mjs +0 -24
  138. package/dist/auth-kit/google_auth.d.mts +0 -27
  139. package/dist/auth-kit/google_auth.d.ts +0 -27
  140. package/dist/auth-kit/kakao_auth.d.mts +0 -24
  141. package/dist/auth-kit/kakao_auth.d.ts +0 -24
  142. package/dist/auth-kit/with_auth.mjs +0 -47
  143. package/dist/file-kit/file_service.d.mts +0 -26
  144. package/dist/file-kit/file_service.d.ts +0 -26
  145. package/dist/file-kit/file_service.mjs +0 -35
  146. package/dist/route/api/auth/login/_provider_/route.d.mts +0 -20
  147. package/dist/route/api/auth/login/_provider_/route.d.ts +0 -20
  148. package/dist/route/api/auth/login/route.d.mts +0 -14
  149. package/dist/route/api/auth/login/route.d.ts +0 -14
  150. package/dist/route/api/auth/logout/route.d.mts +0 -14
  151. package/dist/route/api/auth/logout/route.d.ts +0 -14
  152. package/dist/route/api/auth/refresh/route.d.mts +0 -13
  153. package/dist/route/api/auth/refresh/route.d.ts +0 -13
  154. package/dist/route/api/auth/route.d.mts +0 -13
  155. package/dist/route/api/auth/route.d.ts +0 -13
  156. package/dist/route/api/files/_fileId_/route.d.mts +0 -17
  157. package/dist/route/api/files/_fileId_/route.d.ts +0 -17
  158. package/dist/route/api/files/route.d.mts +0 -16
  159. package/dist/route/api/files/route.d.ts +0 -16
  160. package/dist/route/auth/callback/_provider_/route.d.mts +0 -20
  161. package/dist/route/auth/callback/_provider_/route.d.ts +0 -20
  162. /package/dist/{auth-kit/repository.mjs → auth/auth_repository.mjs} +0 -0
  163. /package/dist/{auth-kit → auth}/client/redirect_page.d.mts +0 -0
  164. /package/dist/{auth-kit → auth}/client/redirect_page.d.ts +0 -0
  165. /package/dist/{file-kit → file}/cdn.d.mts +0 -0
  166. /package/dist/{file-kit → file}/cdn.d.ts +0 -0
  167. /package/dist/{file-kit → file}/client/drop_file_input.d.mts +0 -0
  168. /package/dist/{file-kit → file}/client/drop_file_input.d.ts +0 -0
  169. /package/dist/{file-kit → file}/client/file_upload_button.d.mts +0 -0
  170. /package/dist/{file-kit → file}/client/file_upload_button.d.ts +0 -0
  171. /package/dist/{file-kit → file}/client/file_uploader.d.mts +0 -0
  172. /package/dist/{file-kit → file}/client/file_uploader.d.ts +0 -0
  173. /package/dist/{file-kit → file}/client/format_size.d.mts +0 -0
  174. /package/dist/{file-kit → file}/client/format_size.d.ts +0 -0
  175. /package/dist/{file-kit → file}/client/metadata.d.mts +0 -0
  176. /package/dist/{file-kit → file}/client/metadata.d.ts +0 -0
  177. /package/dist/{file-kit/repository.mjs → file/file_repository.mjs} +0 -0
  178. /package/dist/{http-kit → http}/index.d.mts +0 -0
  179. /package/dist/{http-kit → http}/index.d.ts +0 -0
  180. /package/dist/{http-kit → http}/response.d.mts +0 -0
  181. /package/dist/{http-kit → http}/response.d.ts +0 -0
  182. /package/dist/{seo-kit → seo}/seo.d.mts +0 -0
  183. /package/dist/{seo-kit → seo}/seo.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- // src/http-kit/response.ts
1
+ // src/http/response.ts
2
2
  var createJsonResponse = (status) => {
3
3
  return (data = {}, init) => {
4
4
  return Response.json(data, { status, ...init });
@@ -48,59 +48,68 @@ var INTERNAL_SERVER_ERROR = createException(
48
48
  "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
49
49
  );
50
50
 
51
- // src/route/auth/callback/[provider]/route.tsx
52
- var thirdPartyAuthCallbackHandler = async (request, {
53
- provider
54
- }, {
55
- AUTH,
56
- GOOGLE_AUTH,
57
- APPLE_AUTH,
58
- SITE_ORIGIN
51
+ // src/auth/handlers/thirdparty_auth_callback.tsx
52
+ var thirdpartyAuthCallbackHandler = async (request, {
53
+ provider,
54
+ authService,
55
+ getThirdPartyAuth
59
56
  }) => {
60
57
  const url = new URL(request.url);
61
58
  const code = url.searchParams.get("code");
62
59
  if (!code) {
63
60
  throw BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
64
61
  }
65
- const getThirdPartyAuth = (provider2) => {
66
- switch (provider2) {
67
- case "google":
68
- return GOOGLE_AUTH;
69
- case "apple":
70
- return APPLE_AUTH;
71
- default:
72
- throw BAD_REQUEST("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC778\uC99D \uC81C\uACF5\uC790\uC785\uB2C8\uB2E4.");
73
- }
74
- };
75
- const { accessToken, refreshToken } = await getThirdPartyAuth(
76
- provider
77
- ).signIn(code);
78
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
79
- AUTH.getAccessTokenSetCookie(accessToken),
80
- AUTH.getRefreshTokenSetCookie(refreshToken)
81
- ]);
82
- const headers = new Headers();
83
- headers.append("Set-Cookie", accessTokenSetCookie);
84
- headers.append("Set-Cookie", refreshTokenSetCookie);
85
- const redirectUrl = url.searchParams.get("state") || SITE_ORIGIN;
86
- return new Response("Temporary Redirect", {
87
- status: 307,
88
- headers: {
89
- ...headers,
90
- Location: new URL(
91
- `/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
92
- request.url
93
- ).toString()
62
+ try {
63
+ const { accessToken, refreshToken } = await getThirdPartyAuth(
64
+ provider
65
+ ).login(code);
66
+ const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
67
+ authService.getAccessTokenSetCookie(accessToken),
68
+ authService.getRefreshTokenSetCookie(refreshToken)
69
+ ]);
70
+ const headers = new Headers();
71
+ headers.append("Set-Cookie", accessTokenSetCookie);
72
+ headers.append("Set-Cookie", refreshTokenSetCookie);
73
+ const redirectUrl = url.searchParams.get("state") || "/";
74
+ return new Response("Temporary Redirect", {
75
+ status: 307,
76
+ headers: {
77
+ ...headers,
78
+ Location: new URL(
79
+ `/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
80
+ request.url
81
+ ).toString()
82
+ }
83
+ });
84
+ } catch (error) {
85
+ if (error instanceof Response) {
86
+ if (error.status == 404) {
87
+ const body = await error.json();
88
+ const token = body.token;
89
+ return new Response(
90
+ "Temporary Redirect",
91
+ {
92
+ status: 307,
93
+ headers: {
94
+ Location: new URL(
95
+ `/signup?token=${token}`,
96
+ request.url
97
+ ).toString()
98
+ }
99
+ }
100
+ );
101
+ }
94
102
  }
95
- });
103
+ throw error;
104
+ }
96
105
  };
97
106
 
98
- // src/route/api/files/route.ts
99
- var fileUploadHandler = async (request, {
100
- AUTH,
101
- FILE_SERVICE
107
+ // src/file/handlers/upload_file.ts
108
+ var uploadFileHandler = async (request, {
109
+ authService,
110
+ fileService
102
111
  }) => {
103
- const auth = await AUTH.verifyOrRefresh(request);
112
+ const auth = await authService.verifyOrRefresh(request);
104
113
  const { name, type, size, metadata } = await request.json();
105
114
  const headers = {
106
115
  "Access-Control-Allow-Origin": "*"
@@ -112,7 +121,7 @@ var fileUploadHandler = async (request, {
112
121
  return BAD_REQUEST("\uD30C\uC77C \uD0C0\uC785\uC774 \uD544\uC694\uD574\uC694.", { headers });
113
122
  }
114
123
  try {
115
- const result = await FILE_SERVICE.generateSignedUrl({
124
+ const result = await fileService.generateSignedUrl({
116
125
  userId: auth?.userId,
117
126
  name,
118
127
  type,
@@ -128,63 +137,48 @@ var fileUploadHandler = async (request, {
128
137
  }
129
138
  };
130
139
 
131
- // src/route/api/files/[fileId]/route.ts
132
- var fileDeleteHandler = async (request, { fileId }, {
133
- AUTH,
134
- repository
140
+ // src/file/handlers/delete_file.ts
141
+ var deleteFileHandler = async (request, { fileId }, {
142
+ authService,
143
+ fileRepository
135
144
  }) => {
136
- const auth = await AUTH.verifyOrRefresh(request);
137
- const file = await repository.findFileById(fileId);
145
+ const auth = await authService.verifyOrRefresh(request);
146
+ const file = await fileRepository.findFileById(fileId);
138
147
  const headers = {
139
148
  "Access-Control-Allow-Origin": "*"
140
149
  };
141
150
  if (!file) {
142
151
  return NOT_FOUND("\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
143
152
  }
144
- if (!repository.hasPermission(file, auth?.userId)) {
153
+ if (!fileRepository.hasPermission(file, auth?.userId)) {
145
154
  return FORBIDDEN("\uD30C\uC77C\uC744 \uC0AD\uC81C\uD560 \uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
146
155
  }
147
- await repository.deleteFile(fileId);
156
+ await fileRepository.deleteFile(fileId);
148
157
  return NO_CONTENT({ headers });
149
158
  };
150
159
 
151
- // src/route/api/auth/route.ts
152
- var getAuthHandler = async (request, { AUTH }) => {
153
- const auth = await AUTH.verifyOrRefresh(request);
160
+ // src/auth/handlers/find_auth.ts
161
+ var findAuthHandler = async (request, { authService }) => {
162
+ const auth = await authService.verifyOrRefresh(request);
154
163
  if (!auth) {
155
164
  return UNAUTHORIZED();
156
165
  }
157
166
  return OK(auth);
158
167
  };
159
168
 
160
- // src/route/api/auth/login/[provider]/route.ts
161
- var loginThirdPartyHandler = async (request, {
162
- provider
163
- }, {
164
- GOOGLE_AUTH,
165
- APPLE_AUTH,
166
- KAKAO_AUTH
169
+ // src/auth/handlers/login_with_thirdparty.ts
170
+ var loginWithThirdPartyHandler = async (request, {
171
+ provider,
172
+ getThirdPartyAuth
167
173
  }) => {
168
174
  const { code } = await request.json();
169
175
  if (!code) {
170
176
  return BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
171
177
  }
172
- const getThirdPartyAuth = (provider2) => {
173
- switch (provider2) {
174
- case "google":
175
- return GOOGLE_AUTH;
176
- case "apple":
177
- return APPLE_AUTH;
178
- case "kakao":
179
- return KAKAO_AUTH;
180
- default:
181
- throw BAD_REQUEST("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC778\uC99D \uC81C\uACF5\uC790\uC785\uB2C8\uB2E4.");
182
- }
183
- };
184
178
  try {
185
179
  const { accessToken, refreshToken } = await getThirdPartyAuth(
186
180
  provider
187
- ).signIn(code);
181
+ ).login(code);
188
182
  return CREATED({
189
183
  accessToken,
190
184
  refreshToken
@@ -197,26 +191,26 @@ var loginThirdPartyHandler = async (request, {
197
191
  }
198
192
  };
199
193
 
200
- // src/route/api/auth/login/route.ts
201
- var loginCredentialHandler = async (request, {
202
- AUTH,
203
- JWT_MANAGER
194
+ // src/auth/handlers/login.ts
195
+ var loginHandler = async (request, {
196
+ authService
204
197
  }) => {
205
- const searchParams = new URL(request.url).searchParams;
206
198
  const { id, password } = await request.json();
207
199
  try {
208
- const { accessToken, refreshToken } = await AUTH.signIn({
200
+ const { accessToken, refreshToken } = await authService.signIn({
209
201
  id,
210
202
  password
211
203
  });
212
- if (searchParams.get("type") === "json") {
204
+ const searchParams = new URL(request.url).searchParams;
205
+ const type = searchParams.get("type");
206
+ if (type === "json") {
213
207
  return CREATED({ accessToken, refreshToken });
214
208
  }
215
209
  const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
216
- AUTH.getAccessTokenSetCookie(accessToken),
217
- AUTH.getRefreshTokenSetCookie(refreshToken)
210
+ authService.getAccessTokenSetCookie(accessToken),
211
+ authService.getRefreshTokenSetCookie(refreshToken)
218
212
  ]);
219
- const payload = JWT_MANAGER.decode(accessToken);
213
+ const payload = authService.jwtManager.decode(accessToken);
220
214
  const headers = new Headers();
221
215
  headers.append("Set-Cookie", accessTokenSetCookie);
222
216
  headers.append("Set-Cookie", refreshTokenSetCookie);
@@ -231,17 +225,21 @@ var loginCredentialHandler = async (request, {
231
225
  }
232
226
  };
233
227
 
234
- // src/route/api/auth/logout/route.ts
235
- var logoutHandler = async (request, { AUTH, repository }) => {
236
- const auth = await AUTH.verifyOrRefresh(request);
228
+ // src/auth/handlers/logout.ts
229
+ var logoutHandler = async (request, { authService }) => {
230
+ const auth = await authService.verifyOrRefresh(request);
237
231
  if (!auth) {
238
232
  return UNAUTHORIZED();
239
233
  }
240
- await repository.updateUserRefreshToken(auth.userId, null);
234
+ await authService.authRepository.updateUserRefreshToken(auth.userId, null);
235
+ const type = new URL(request.url).searchParams.get("type");
236
+ if (type === "json") {
237
+ return NO_CONTENT();
238
+ }
241
239
  const headers = new Headers();
242
240
  const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
243
- AUTH.getAccessTokenSetCookie(null),
244
- AUTH.getRefreshTokenSetCookie(null)
241
+ authService.getAccessTokenSetCookie(null),
242
+ authService.getRefreshTokenSetCookie(null)
245
243
  ]);
246
244
  headers.append("Set-Cookie", accessTokenSetCookie);
247
245
  headers.append("Set-Cookie", refreshTokenSetCookie);
@@ -250,16 +248,16 @@ var logoutHandler = async (request, { AUTH, repository }) => {
250
248
  });
251
249
  };
252
250
 
253
- // src/route/api/auth/refresh/route.ts
254
- var authRefreshHandler = async (request, {
255
- AUTH
251
+ // src/auth/handlers/refresh.ts
252
+ var refreshHandler = async (request, {
253
+ authService
256
254
  }) => {
257
- const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await AUTH.getRefreshTokenFromCookies(request);
255
+ const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await authService.getRefreshTokenFromCookies(request);
258
256
  if (!refreshToken) {
259
257
  return BAD_REQUEST();
260
258
  }
261
259
  try {
262
- const accessToken = await AUTH.refreshAccessToken(refreshToken);
260
+ const accessToken = await authService.refreshAccessToken(refreshToken);
263
261
  return CREATED({ accessToken });
264
262
  } catch (e) {
265
263
  if (e instanceof Error) {
@@ -269,100 +267,239 @@ var authRefreshHandler = async (request, {
269
267
  }
270
268
  };
271
269
 
272
- // src/route/api.ts
273
- var createAuthAPIHandler = ({
274
- AUTH,
275
- GOOGLE_AUTH,
276
- APPLE_AUTH,
277
- KAKAO_AUTH,
278
- JWT_MANAGER,
279
- FILE_SERVICE,
280
- SITE_ORIGIN,
281
- authRepository,
270
+ // src/auth/handlers/signup.ts
271
+ import { v5 } from "uuid";
272
+ import * as bcrypt from "bcryptjs";
273
+ var signupHandler = async (request, {
274
+ authService,
282
275
  fileRepository
283
276
  }) => {
284
- const handler = async ({
285
- request,
286
- params
287
- }) => {
277
+ const body = await request.json();
278
+ const {
279
+ email,
280
+ password,
281
+ passwordConfirm,
282
+ name,
283
+ profileImageId
284
+ } = body;
285
+ if (!email) {
286
+ return BAD_REQUEST("\uC774\uBA54\uC77C\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
287
+ }
288
+ if (!password) {
289
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
290
+ }
291
+ if (!passwordConfirm) {
292
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638 \uD655\uC778\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
293
+ }
294
+ if (!name) {
295
+ return BAD_REQUEST("\uC774\uB984\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
296
+ }
297
+ const existing = await authService.authRepository.findCredentialById(email);
298
+ if (existing) {
299
+ return CONFLICT("\uC774\uBA54\uC77C\uC774 \uC774\uBBF8 \uC874\uC7AC\uD569\uB2C8\uB2E4.");
300
+ }
301
+ if (password !== passwordConfirm) {
302
+ return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
303
+ }
304
+ const profileImage = profileImageId ? await fileRepository.findFileById(profileImageId) : void 0;
305
+ const userId = v5(email, v5.DNS);
306
+ const user = await authService.authRepository.createUser({
307
+ id: userId,
308
+ name,
309
+ role: "user",
310
+ email,
311
+ profileImage
312
+ });
313
+ await authService.authRepository.createCredential({
314
+ id: email,
315
+ userId,
316
+ password: bcrypt.hashSync(password, 10)
317
+ });
318
+ const { accessToken, refreshToken } = await authService.issueTokenPair(user);
319
+ return CREATED({ accessToken, refreshToken });
320
+ };
321
+
322
+ // src/auth/handlers/signup_with_thirdparty.ts
323
+ import { v5 as v52 } from "uuid";
324
+ var signUpWithThirdpartyHandler = async (request, {
325
+ authService,
326
+ fileService,
327
+ signupTokenSecret
328
+ }) => {
329
+ const body = await request.json();
330
+ const {
331
+ token
332
+ } = body;
333
+ const payload = await authService.jwtManager.verify(token, signupTokenSecret);
334
+ const { provider, id: thirdpartyId, email, name, picture } = payload;
335
+ const existing = await authService.authRepository.findThirdPartyAuth(
336
+ provider,
337
+ thirdpartyId
338
+ );
339
+ if (existing) {
340
+ return CONFLICT("\uC774\uBBF8 \uAC00\uC785\uB41C \uC81C3\uC790 \uC778\uC99D \uC815\uBCF4\uC785\uB2C8\uB2E4.");
341
+ }
342
+ const userId = v52(thirdpartyId, v52.DNS);
343
+ const profileImage = await (async () => {
344
+ if (!picture) {
345
+ return;
346
+ }
347
+ const arrayBuffer = await fetch(picture).then((res) => res.arrayBuffer());
348
+ const { file } = await fileService.putFile(Buffer.from(arrayBuffer), {
349
+ userId,
350
+ name: "profile.jpg",
351
+ type: "image/jpeg",
352
+ size: arrayBuffer.byteLength
353
+ });
354
+ return file;
355
+ })();
356
+ const user = await authService.authRepository.createUser({
357
+ id: userId,
358
+ name,
359
+ role: "user",
360
+ email,
361
+ profileImage
362
+ });
363
+ await authService.authRepository.createThirdPartyAuth({
364
+ id: thirdpartyId,
365
+ provider,
366
+ userId
367
+ });
368
+ const { accessToken, refreshToken } = await authService.issueTokenPair(user);
369
+ return CREATED({ accessToken, refreshToken });
370
+ };
371
+
372
+ // src/route/api.ts
373
+ var createAPIHandler = ({
374
+ authService,
375
+ fileService,
376
+ getThirdPartyAuth,
377
+ signupTokenSecret
378
+ }) => {
379
+ const handler = async ({ request, params }) => {
288
380
  const method = request.method.toUpperCase();
289
- const slug = params["*"].split("/");
290
- if (slug[0] === "auth") {
291
- if (!slug[1]) {
292
- if (method === "GET") {
293
- return getAuthHandler(request, { AUTH });
294
- }
295
- }
296
- if (slug[1] === "login") {
297
- if (slug[2]) {
298
- const provider = slug[2];
299
- if (method === "POST") {
300
- return loginThirdPartyHandler(
301
- request,
302
- { provider },
303
- { GOOGLE_AUTH, KAKAO_AUTH, APPLE_AUTH }
304
- );
381
+ const slug = params["*"] ? params["*"].split("/") : [];
382
+ switch (slug[0]) {
383
+ case "auth": {
384
+ switch (slug[1]) {
385
+ case void 0: {
386
+ switch (method) {
387
+ case "GET": {
388
+ return findAuthHandler(request, { authService });
389
+ }
390
+ }
305
391
  }
306
- }
307
- if (method === "POST") {
308
- return loginCredentialHandler(request, {
309
- AUTH,
310
- JWT_MANAGER
311
- });
312
- }
313
- }
314
- if (slug[1] === "logout") {
315
- if (method === "POST") {
316
- return logoutHandler(request, {
317
- AUTH,
318
- repository: authRepository
319
- });
320
- }
321
- }
322
- if (slug[1] === "refresh") {
323
- if (method === "GET") {
324
- return authRefreshHandler(request, { AUTH });
325
- }
326
- }
327
- if (slug[1] === "callback") {
328
- if (slug[2]) {
329
- const provider = slug[2];
330
- if (method === "GET") {
331
- return thirdPartyAuthCallbackHandler(
332
- request,
333
- { provider },
334
- {
335
- AUTH,
336
- GOOGLE_AUTH,
337
- APPLE_AUTH,
338
- SITE_ORIGIN
392
+ case "login": {
393
+ switch (slug[2]) {
394
+ case void 0: {
395
+ switch (method) {
396
+ case "POST": {
397
+ return loginHandler(request, {
398
+ authService
399
+ });
400
+ }
401
+ }
402
+ }
403
+ default: {
404
+ const provider = slug[2];
405
+ switch (method) {
406
+ case "POST": {
407
+ return loginWithThirdPartyHandler(
408
+ request,
409
+ { provider, getThirdPartyAuth }
410
+ );
411
+ }
412
+ }
413
+ }
414
+ }
415
+ }
416
+ case "logout": {
417
+ switch (method) {
418
+ case "POST": {
419
+ return logoutHandler(request, {
420
+ authService
421
+ });
422
+ }
423
+ }
424
+ }
425
+ case "refresh": {
426
+ switch (method) {
427
+ case "GET": {
428
+ return refreshHandler(request, { authService });
429
+ }
430
+ }
431
+ }
432
+ case "signup": {
433
+ switch (slug[2]) {
434
+ case void 0: {
435
+ switch (method) {
436
+ case "POST": {
437
+ return signupHandler(request, {
438
+ authService,
439
+ fileRepository: fileService.fileRepository
440
+ });
441
+ }
442
+ }
339
443
  }
340
- );
444
+ default: {
445
+ switch (method) {
446
+ case "POST": {
447
+ return signUpWithThirdpartyHandler(
448
+ request,
449
+ { authService, fileService, signupTokenSecret }
450
+ );
451
+ }
452
+ }
453
+ }
454
+ }
455
+ }
456
+ case "callback": {
457
+ if (slug[2]) {
458
+ const provider = slug[2];
459
+ if (method === "GET") {
460
+ return thirdpartyAuthCallbackHandler(
461
+ request,
462
+ {
463
+ provider,
464
+ authService,
465
+ getThirdPartyAuth
466
+ }
467
+ );
468
+ }
469
+ }
341
470
  }
342
471
  }
343
472
  }
344
- }
345
- if (slug[0] === "files") {
346
- if (!slug[1]) {
347
- if (method === "POST") {
348
- return fileUploadHandler(request, { AUTH, FILE_SERVICE });
473
+ case "files": {
474
+ switch (slug[1]) {
475
+ case void 0: {
476
+ switch (method) {
477
+ case "POST": {
478
+ return uploadFileHandler(request, { authService, fileService });
479
+ }
480
+ }
481
+ }
482
+ default: {
483
+ switch (method) {
484
+ case "DELETE": {
485
+ const fileId = slug[1];
486
+ return deleteFileHandler(
487
+ request,
488
+ { fileId },
489
+ { authService, fileRepository: fileService.fileRepository }
490
+ );
491
+ }
492
+ }
493
+ }
349
494
  }
350
495
  }
351
- if (slug[1]) {
352
- if (method === "DELETE") {
353
- const fileId = slug[1];
354
- return fileDeleteHandler(
355
- request,
356
- { fileId },
357
- { AUTH, repository: fileRepository }
358
- );
359
- }
496
+ default: {
497
+ return NOT_FOUND();
360
498
  }
361
499
  }
362
- return new Response("Not Found", { status: 404 });
363
500
  };
364
501
  return handler;
365
502
  };
366
503
  export {
367
- createAuthAPIHandler
504
+ createAPIHandler
368
505
  };
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/seo-kit/seo.tsx
30
+ // src/seo/seo.tsx
31
31
  var seo_exports = {};
32
32
  __export(seo_exports, {
33
33
  configSEO: () => configSEO
@@ -1,4 +1,4 @@
1
- // src/seo-kit/seo.tsx
1
+ // src/seo/seo.tsx
2
2
  import React from "react";
3
3
  import { useMatches } from "react-router";
4
4
  function configSEO(config) {