dn-react-router-toolkit 0.2.6 → 0.3.1

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 (278) hide show
  1. package/dist/api/create_handler.d.mts +13 -0
  2. package/dist/api/create_handler.d.ts +13 -0
  3. package/dist/api/create_handler.js +276 -0
  4. package/dist/api/create_handler.mjs +282 -0
  5. package/dist/api/index.d.mts +4 -0
  6. package/dist/api/index.d.ts +4 -0
  7. package/dist/api/index.js +276 -0
  8. package/dist/api/index.mjs +282 -0
  9. package/dist/auth/client/index.d.mts +3 -0
  10. package/dist/auth/client/index.d.ts +3 -0
  11. package/dist/{date.js → auth/client/index.js} +25 -32
  12. package/dist/auth/client/index.mjs +21 -0
  13. package/dist/auth/client/redirect_page.d.mts +1 -0
  14. package/dist/auth/client/redirect_page.d.ts +1 -0
  15. package/dist/auth/index.d.mts +4 -0
  16. package/dist/auth/index.d.ts +4 -0
  17. package/dist/auth/index.js +116 -0
  18. package/dist/auth/index.mjs +89 -0
  19. package/dist/auth/server/index.d.mts +1 -0
  20. package/dist/auth/server/index.d.ts +1 -0
  21. package/dist/{slug.js → auth/server/index.js} +6 -14
  22. package/dist/auth/server/index.mjs +2 -0
  23. package/dist/auth/with_auth.d.mts +2 -6
  24. package/dist/auth/with_auth.d.ts +2 -6
  25. package/dist/auth/with_auth.js +3 -0
  26. package/dist/auth/with_auth.mjs +3 -0
  27. package/dist/{components → client}/client_env.d.mts +1 -1
  28. package/dist/{components → client}/client_env.d.ts +1 -1
  29. package/dist/{components → client}/client_env.js +6 -2
  30. package/dist/{components → client}/client_env.mjs +2 -2
  31. package/dist/client/index.d.mts +3 -0
  32. package/dist/client/index.d.ts +3 -0
  33. package/dist/{auth/client/google_login_button.js → client/index.js} +30 -33
  34. package/dist/client/index.mjs +31 -0
  35. package/dist/client/use_user_agent.d.mts +8 -0
  36. package/dist/client/use_user_agent.d.ts +8 -0
  37. package/dist/{file/client/format_size.js → client/use_user_agent.js} +14 -14
  38. package/dist/client/use_user_agent.mjs +13 -0
  39. package/dist/file/client/index.d.mts +1 -0
  40. package/dist/file/client/index.d.ts +1 -0
  41. package/dist/file/{cdn.js → client/index.js} +6 -16
  42. package/dist/file/client/index.mjs +2 -0
  43. package/dist/file/index.d.mts +1 -0
  44. package/dist/file/index.d.ts +1 -0
  45. package/dist/{cn.js → file/index.js} +6 -14
  46. package/dist/file/index.mjs +2 -0
  47. package/dist/file/server/index.d.mts +1 -0
  48. package/dist/file/server/index.d.ts +1 -0
  49. package/dist/file/server/index.js +24 -0
  50. package/dist/file/server/index.mjs +2 -0
  51. package/dist/http/index.d.mts +1 -1
  52. package/dist/http/index.d.ts +1 -1
  53. package/dist/http/index.js +3 -90
  54. package/dist/http/index.mjs +2 -68
  55. package/dist/index.d.mts +8 -6
  56. package/dist/index.d.ts +8 -6
  57. package/dist/index.js +3 -79
  58. package/dist/index.mjs +2 -58
  59. package/dist/modal/index.d.mts +1 -0
  60. package/dist/modal/index.d.ts +1 -0
  61. package/dist/{sleep.js → modal/index.js} +6 -14
  62. package/dist/modal/index.mjs +2 -0
  63. package/dist/seo/index.d.mts +4 -0
  64. package/dist/seo/index.d.ts +4 -0
  65. package/dist/seo/index.js +304 -0
  66. package/dist/seo/index.mjs +267 -0
  67. package/dist/seo/seo.js +9 -1
  68. package/dist/seo/seo.mjs +9 -1
  69. package/dist/text_editor/index.d.mts +1 -0
  70. package/dist/text_editor/index.d.ts +1 -0
  71. package/dist/text_editor/index.js +24 -0
  72. package/dist/text_editor/index.mjs +2 -0
  73. package/package.json +58 -32
  74. package/dist/auth/apple_auth.d.mts +0 -38
  75. package/dist/auth/apple_auth.d.ts +0 -38
  76. package/dist/auth/apple_auth.js +0 -88
  77. package/dist/auth/apple_auth.mjs +0 -63
  78. package/dist/auth/auth_repository.d.mts +0 -41
  79. package/dist/auth/auth_repository.d.ts +0 -41
  80. package/dist/auth/auth_repository.js +0 -18
  81. package/dist/auth/auth_repository.mjs +0 -0
  82. package/dist/auth/auth_service.d.mts +0 -63
  83. package/dist/auth/auth_service.d.ts +0 -63
  84. package/dist/auth/auth_service.js +0 -210
  85. package/dist/auth/auth_service.mjs +0 -171
  86. package/dist/auth/client/google_login_button.d.mts +0 -7
  87. package/dist/auth/client/google_login_button.d.ts +0 -7
  88. package/dist/auth/client/google_login_button.mjs +0 -37
  89. package/dist/auth/client/provider.d.mts +0 -24
  90. package/dist/auth/client/provider.d.ts +0 -24
  91. package/dist/auth/client/provider.js +0 -154
  92. package/dist/auth/client/provider.mjs +0 -118
  93. package/dist/auth/google_auth.d.mts +0 -33
  94. package/dist/auth/google_auth.d.ts +0 -33
  95. package/dist/auth/google_auth.js +0 -135
  96. package/dist/auth/google_auth.mjs +0 -108
  97. package/dist/auth/handlers/find_auth.d.mts +0 -13
  98. package/dist/auth/handlers/find_auth.d.ts +0 -13
  99. package/dist/auth/handlers/find_auth.js +0 -82
  100. package/dist/auth/handlers/find_auth.mjs +0 -55
  101. package/dist/auth/handlers/login.d.mts +0 -13
  102. package/dist/auth/handlers/login.d.ts +0 -13
  103. package/dist/auth/handlers/login.js +0 -107
  104. package/dist/auth/handlers/login.mjs +0 -80
  105. package/dist/auth/handlers/login_with_thirdparty.d.mts +0 -15
  106. package/dist/auth/handlers/login_with_thirdparty.d.ts +0 -15
  107. package/dist/auth/handlers/login_with_thirdparty.js +0 -98
  108. package/dist/auth/handlers/login_with_thirdparty.mjs +0 -71
  109. package/dist/auth/handlers/logout.d.mts +0 -13
  110. package/dist/auth/handlers/logout.d.ts +0 -13
  111. package/dist/auth/handlers/logout.js +0 -102
  112. package/dist/auth/handlers/logout.mjs +0 -75
  113. package/dist/auth/handlers/refresh.d.mts +0 -13
  114. package/dist/auth/handlers/refresh.d.ts +0 -13
  115. package/dist/auth/handlers/refresh.js +0 -92
  116. package/dist/auth/handlers/refresh.mjs +0 -65
  117. package/dist/auth/handlers/request_password_reset.d.mts +0 -10
  118. package/dist/auth/handlers/request_password_reset.d.ts +0 -10
  119. package/dist/auth/handlers/request_password_reset.js +0 -87
  120. package/dist/auth/handlers/request_password_reset.mjs +0 -60
  121. package/dist/auth/handlers/reset_password.d.mts +0 -10
  122. package/dist/auth/handlers/reset_password.d.ts +0 -10
  123. package/dist/auth/handlers/reset_password.js +0 -88
  124. package/dist/auth/handlers/reset_password.mjs +0 -61
  125. package/dist/auth/handlers/signup.d.mts +0 -15
  126. package/dist/auth/handlers/signup.d.ts +0 -15
  127. package/dist/auth/handlers/signup.js +0 -147
  128. package/dist/auth/handlers/signup.mjs +0 -112
  129. package/dist/auth/handlers/signup_with_thirdparty.d.mts +0 -17
  130. package/dist/auth/handlers/signup_with_thirdparty.d.ts +0 -17
  131. package/dist/auth/handlers/signup_with_thirdparty.js +0 -123
  132. package/dist/auth/handlers/signup_with_thirdparty.mjs +0 -98
  133. package/dist/auth/handlers/thirdparty_auth_callback.d.mts +0 -16
  134. package/dist/auth/handlers/thirdparty_auth_callback.d.ts +0 -16
  135. package/dist/auth/handlers/thirdparty_auth_callback.js +0 -129
  136. package/dist/auth/handlers/thirdparty_auth_callback.mjs +0 -102
  137. package/dist/auth/jwt_manager.d.mts +0 -38
  138. package/dist/auth/jwt_manager.d.ts +0 -38
  139. package/dist/auth/jwt_manager.js +0 -90
  140. package/dist/auth/jwt_manager.mjs +0 -65
  141. package/dist/auth/kakao_auth.d.mts +0 -27
  142. package/dist/auth/kakao_auth.d.ts +0 -27
  143. package/dist/auth/kakao_auth.js +0 -56
  144. package/dist/auth/kakao_auth.mjs +0 -31
  145. package/dist/auth/password_recovery.d.mts +0 -34
  146. package/dist/auth/password_recovery.d.ts +0 -34
  147. package/dist/auth/password_recovery.js +0 -169
  148. package/dist/auth/password_recovery.mjs +0 -134
  149. package/dist/auth/thirdparty_auth.d.mts +0 -41
  150. package/dist/auth/thirdparty_auth.d.ts +0 -41
  151. package/dist/auth/thirdparty_auth.js +0 -113
  152. package/dist/auth/thirdparty_auth.mjs +0 -86
  153. package/dist/cn.d.mts +0 -3
  154. package/dist/cn.d.ts +0 -3
  155. package/dist/cn.mjs +0 -7
  156. package/dist/components/index.d.mts +0 -5
  157. package/dist/components/index.d.ts +0 -5
  158. package/dist/components/index.js +0 -261
  159. package/dist/components/index.mjs +0 -219
  160. package/dist/components/modal/fullscreen_container.d.mts +0 -7
  161. package/dist/components/modal/fullscreen_container.d.ts +0 -7
  162. package/dist/components/modal/fullscreen_container.js +0 -102
  163. package/dist/components/modal/fullscreen_container.mjs +0 -68
  164. package/dist/components/modal/hooks.d.mts +0 -18
  165. package/dist/components/modal/hooks.d.ts +0 -18
  166. package/dist/components/modal/hooks.js +0 -236
  167. package/dist/components/modal/hooks.mjs +0 -204
  168. package/dist/components/modal/index.d.mts +0 -4
  169. package/dist/components/modal/index.d.ts +0 -4
  170. package/dist/components/modal/index.js +0 -238
  171. package/dist/components/modal/index.mjs +0 -203
  172. package/dist/components/modal/modal.d.mts +0 -13
  173. package/dist/components/modal/modal.d.ts +0 -13
  174. package/dist/components/modal/modal.js +0 -155
  175. package/dist/components/modal/modal.mjs +0 -130
  176. package/dist/components/styles.d.mts +0 -9
  177. package/dist/components/styles.d.ts +0 -9
  178. package/dist/components/styles.js +0 -48
  179. package/dist/components/styles.mjs +0 -17
  180. package/dist/date.d.mts +0 -5
  181. package/dist/date.d.ts +0 -5
  182. package/dist/date.mjs +0 -29
  183. package/dist/file/cdn.d.mts +0 -6
  184. package/dist/file/cdn.d.ts +0 -6
  185. package/dist/file/cdn.mjs +0 -9
  186. package/dist/file/client/drop_file_input.d.mts +0 -36
  187. package/dist/file/client/drop_file_input.d.ts +0 -36
  188. package/dist/file/client/drop_file_input.js +0 -323
  189. package/dist/file/client/drop_file_input.mjs +0 -294
  190. package/dist/file/client/file_upload_button.d.mts +0 -10
  191. package/dist/file/client/file_upload_button.d.ts +0 -10
  192. package/dist/file/client/file_upload_button.js +0 -89
  193. package/dist/file/client/file_upload_button.mjs +0 -58
  194. package/dist/file/client/file_uploader.d.mts +0 -13
  195. package/dist/file/client/file_uploader.d.ts +0 -13
  196. package/dist/file/client/file_uploader.js +0 -163
  197. package/dist/file/client/file_uploader.mjs +0 -136
  198. package/dist/file/client/format_size.d.mts +0 -3
  199. package/dist/file/client/format_size.d.ts +0 -3
  200. package/dist/file/client/format_size.mjs +0 -13
  201. package/dist/file/client/metadata.d.mts +0 -7
  202. package/dist/file/client/metadata.d.ts +0 -7
  203. package/dist/file/client/metadata.js +0 -85
  204. package/dist/file/client/metadata.mjs +0 -60
  205. package/dist/file/file_repository.d.mts +0 -16
  206. package/dist/file/file_repository.d.ts +0 -16
  207. package/dist/file/file_repository.js +0 -18
  208. package/dist/file/file_repository.mjs +0 -0
  209. package/dist/file/file_service.d.mts +0 -32
  210. package/dist/file/file_service.d.ts +0 -32
  211. package/dist/file/file_service.js +0 -66
  212. package/dist/file/file_service.mjs +0 -41
  213. package/dist/file/handlers/delete_file.d.mts +0 -17
  214. package/dist/file/handlers/delete_file.d.ts +0 -17
  215. package/dist/file/handlers/delete_file.js +0 -99
  216. package/dist/file/handlers/delete_file.mjs +0 -72
  217. package/dist/file/handlers/upload_file.d.mts +0 -16
  218. package/dist/file/handlers/upload_file.d.ts +0 -16
  219. package/dist/file/handlers/upload_file.js +0 -106
  220. package/dist/file/handlers/upload_file.mjs +0 -79
  221. package/dist/file/object_storage.d.mts +0 -19
  222. package/dist/file/object_storage.d.ts +0 -19
  223. package/dist/file/object_storage.js +0 -78
  224. package/dist/file/object_storage.mjs +0 -57
  225. package/dist/file/responsive_image.d.mts +0 -20
  226. package/dist/file/responsive_image.d.ts +0 -20
  227. package/dist/file/responsive_image.js +0 -132
  228. package/dist/file/responsive_image.mjs +0 -96
  229. package/dist/http/response.d.mts +0 -19
  230. package/dist/http/response.d.ts +0 -19
  231. package/dist/http/response.js +0 -109
  232. package/dist/http/response.mjs +0 -68
  233. package/dist/route/api.d.mts +0 -21
  234. package/dist/route/api.d.ts +0 -21
  235. package/dist/route/api.js +0 -584
  236. package/dist/route/api.mjs +0 -547
  237. package/dist/singleton.d.mts +0 -3
  238. package/dist/singleton.d.ts +0 -3
  239. package/dist/singleton.js +0 -37
  240. package/dist/singleton.mjs +0 -12
  241. package/dist/sleep.d.mts +0 -3
  242. package/dist/sleep.d.ts +0 -3
  243. package/dist/sleep.mjs +0 -7
  244. package/dist/slug.d.mts +0 -3
  245. package/dist/slug.d.ts +0 -3
  246. package/dist/slug.mjs +0 -7
  247. package/dist/text_editor/attach_media.d.mts +0 -16
  248. package/dist/text_editor/attach_media.d.ts +0 -16
  249. package/dist/text_editor/attach_media.js +0 -237
  250. package/dist/text_editor/attach_media.mjs +0 -210
  251. package/dist/text_editor/plugins/drag_and_drop.d.mts +0 -13
  252. package/dist/text_editor/plugins/drag_and_drop.d.ts +0 -13
  253. package/dist/text_editor/plugins/drag_and_drop.js +0 -59
  254. package/dist/text_editor/plugins/drag_and_drop.mjs +0 -34
  255. package/dist/text_editor/plugins/keymap.d.mts +0 -5
  256. package/dist/text_editor/plugins/keymap.d.ts +0 -5
  257. package/dist/text_editor/plugins/keymap.js +0 -40
  258. package/dist/text_editor/plugins/keymap.mjs +0 -15
  259. package/dist/text_editor/plugins/placehoder.d.mts +0 -5
  260. package/dist/text_editor/plugins/placehoder.d.ts +0 -5
  261. package/dist/text_editor/plugins/placehoder.js +0 -112
  262. package/dist/text_editor/plugins/placehoder.mjs +0 -87
  263. package/dist/text_editor/plugins/trailing_paragraph.d.mts +0 -5
  264. package/dist/text_editor/plugins/trailing_paragraph.d.ts +0 -5
  265. package/dist/text_editor/plugins/trailing_paragraph.js +0 -46
  266. package/dist/text_editor/plugins/trailing_paragraph.mjs +0 -21
  267. package/dist/text_editor/plugins/upload_placeholder.d.mts +0 -7
  268. package/dist/text_editor/plugins/upload_placeholder.d.ts +0 -7
  269. package/dist/text_editor/plugins/upload_placeholder.js +0 -94
  270. package/dist/text_editor/plugins/upload_placeholder.mjs +0 -68
  271. package/dist/text_editor/schema.d.mts +0 -9
  272. package/dist/text_editor/schema.d.ts +0 -9
  273. package/dist/text_editor/schema.js +0 -354
  274. package/dist/text_editor/schema.mjs +0 -319
  275. package/dist/text_editor/text_editor.d.mts +0 -44
  276. package/dist/text_editor/text_editor.d.ts +0 -44
  277. package/dist/text_editor/text_editor.js +0 -830
  278. package/dist/text_editor/text_editor.mjs +0 -802
package/dist/route/api.js DELETED
@@ -1,584 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/route/api.ts
31
- var api_exports = {};
32
- __export(api_exports, {
33
- createAPIHandler: () => createAPIHandler
34
- });
35
- module.exports = __toCommonJS(api_exports);
36
-
37
- // src/http/response.ts
38
- var createJsonResponse = (status) => {
39
- return (data = {}, init) => {
40
- return Response.json(data, { status, ...init });
41
- };
42
- };
43
- var OK = createJsonResponse(200);
44
- var CREATED = createJsonResponse(201);
45
- var ACCEPTED = createJsonResponse(202);
46
- var NO_CONTENT = (init) => {
47
- return new Response(null, {
48
- ...init,
49
- status: 204
50
- });
51
- };
52
- var createException = (status, defaultMessage = "\uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.") => {
53
- return (message = defaultMessage, init) => {
54
- return createJsonResponse(status)({ message }, init);
55
- };
56
- };
57
- var BAD_REQUEST = createException(400, "\uC694\uCCAD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
58
- var UNAUTHORIZED = createException(401, "\uC778\uC99D\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.");
59
- var FORBIDDEN = createException(403, "\uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
60
- var NOT_FOUND = createException(
61
- 404,
62
- "\uC694\uCCAD\uD55C \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
63
- );
64
- var METHOD_NOT_ALLOWED = createException(
65
- 405,
66
- "\uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
67
- );
68
- var NOT_ACCEPTABLE = createException(
69
- 406,
70
- "\uC694\uCCAD\uD55C \uD615\uC2DD\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."
71
- );
72
- var REQUEST_TIMEOUT = createException(
73
- 408,
74
- "\uC694\uCCAD \uC2DC\uAC04\uC774 \uCD08\uACFC\uB418\uC5C8\uC2B5\uB2C8\uB2E4."
75
- );
76
- var CONFLICT = createException(409, "\uC694\uCCAD\uC774 \uCDA9\uB3CC\uD588\uC2B5\uB2C8\uB2E4.");
77
- var UNPROCESSABLE_ENTITY = createException(
78
- 422,
79
- "\uCC98\uB9AC\uD560 \uC218 \uC5C6\uB294 \uC5D4\uD2F0\uD2F0\uC785\uB2C8\uB2E4."
80
- );
81
- var TOO_MANY_REQUESTS = createException(429, "\uC694\uCCAD\uC774 \uB108\uBB34 \uB9CE\uC2B5\uB2C8\uB2E4.");
82
- var INTERNAL_SERVER_ERROR = createException(
83
- 500,
84
- "\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
85
- );
86
-
87
- // src/auth/handlers/thirdparty_auth_callback.tsx
88
- var thirdpartyAuthCallbackHandler = async (request, {
89
- provider,
90
- authService,
91
- getThirdPartyAuth
92
- }) => {
93
- const url = new URL(request.url);
94
- const code = url.searchParams.get("code");
95
- if (!code) {
96
- throw BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
97
- }
98
- try {
99
- const { accessToken, refreshToken } = await getThirdPartyAuth(
100
- provider
101
- ).login(code);
102
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
103
- authService.getAccessTokenSetCookie(accessToken),
104
- authService.getRefreshTokenSetCookie(refreshToken)
105
- ]);
106
- const headers = new Headers();
107
- headers.append("Set-Cookie", accessTokenSetCookie);
108
- headers.append("Set-Cookie", refreshTokenSetCookie);
109
- const redirectUrl = url.searchParams.get("state") || "/";
110
- return new Response("Temporary Redirect", {
111
- status: 307,
112
- headers: {
113
- ...headers,
114
- Location: new URL(
115
- `/r?redirectUrl=${encodeURIComponent(redirectUrl)}`,
116
- request.url
117
- ).toString()
118
- }
119
- });
120
- } catch (error) {
121
- if (error instanceof Response) {
122
- if (error.status == 404) {
123
- const body = await error.json();
124
- const token = body.token;
125
- return new Response(
126
- "Temporary Redirect",
127
- {
128
- status: 307,
129
- headers: {
130
- Location: new URL(
131
- `/signup?token=${token}`,
132
- request.url
133
- ).toString()
134
- }
135
- }
136
- );
137
- }
138
- }
139
- throw error;
140
- }
141
- };
142
-
143
- // src/file/handlers/upload_file.ts
144
- var uploadFileHandler = async (request, {
145
- authService,
146
- fileService
147
- }) => {
148
- const auth = await authService.verifyOrRefresh(request);
149
- const { name, type, size, metadata } = await request.json();
150
- const headers = {
151
- "Access-Control-Allow-Origin": "*"
152
- };
153
- if (typeof name !== "string") {
154
- return BAD_REQUEST("\uD30C\uC77C \uC774\uB984\uC774 \uD544\uC694\uD574\uC694.", { headers });
155
- }
156
- if (typeof type !== "string") {
157
- return BAD_REQUEST("\uD30C\uC77C \uD0C0\uC785\uC774 \uD544\uC694\uD574\uC694.", { headers });
158
- }
159
- try {
160
- const result = await fileService.generateSignedUrl({
161
- userId: auth?.userId,
162
- name,
163
- type,
164
- size,
165
- metadata
166
- });
167
- return CREATED(result, { headers });
168
- } catch (e) {
169
- if (e instanceof Error) {
170
- return INTERNAL_SERVER_ERROR(e.message, { headers });
171
- }
172
- return INTERNAL_SERVER_ERROR(e, { headers });
173
- }
174
- };
175
-
176
- // src/file/handlers/delete_file.ts
177
- var deleteFileHandler = async (request, { fileId }, {
178
- authService,
179
- fileRepository
180
- }) => {
181
- const auth = await authService.verifyOrRefresh(request);
182
- const file = await fileRepository.findFileById(fileId);
183
- const headers = {
184
- "Access-Control-Allow-Origin": "*"
185
- };
186
- if (!file) {
187
- return NOT_FOUND("\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
188
- }
189
- if (!fileRepository.hasPermission(file, auth?.userId)) {
190
- return FORBIDDEN("\uD30C\uC77C\uC744 \uC0AD\uC81C\uD560 \uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
191
- }
192
- await fileRepository.deleteFile(fileId);
193
- return NO_CONTENT({ headers });
194
- };
195
-
196
- // src/auth/handlers/find_auth.ts
197
- var findAuthHandler = async (request, { authService }) => {
198
- const auth = await authService.verifyOrRefresh(request);
199
- if (!auth) {
200
- return UNAUTHORIZED();
201
- }
202
- return OK(auth);
203
- };
204
-
205
- // src/auth/handlers/login_with_thirdparty.ts
206
- var loginWithThirdPartyHandler = async (request, {
207
- provider,
208
- getThirdPartyAuth
209
- }) => {
210
- const { code } = await request.json();
211
- if (!code) {
212
- return BAD_REQUEST("\uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
213
- }
214
- try {
215
- const { accessToken, refreshToken } = await getThirdPartyAuth(
216
- provider
217
- ).login(code);
218
- return CREATED({
219
- accessToken,
220
- refreshToken
221
- });
222
- } catch (error) {
223
- if (error instanceof Response) {
224
- return error;
225
- }
226
- throw INTERNAL_SERVER_ERROR();
227
- }
228
- };
229
-
230
- // src/auth/handlers/login.ts
231
- var loginHandler = async (request, {
232
- authService
233
- }) => {
234
- const { id, password } = await request.json();
235
- try {
236
- const { accessToken, refreshToken } = await authService.login({
237
- id,
238
- password
239
- });
240
- const searchParams = new URL(request.url).searchParams;
241
- const type = searchParams.get("type");
242
- if (type === "json") {
243
- return CREATED({ accessToken, refreshToken });
244
- }
245
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
246
- authService.getAccessTokenSetCookie(accessToken),
247
- authService.getRefreshTokenSetCookie(refreshToken)
248
- ]);
249
- const payload = authService.jwtManager.decode(accessToken);
250
- const headers = new Headers();
251
- headers.append("Set-Cookie", accessTokenSetCookie);
252
- headers.append("Set-Cookie", refreshTokenSetCookie);
253
- return CREATED(payload, {
254
- headers
255
- });
256
- } catch (e) {
257
- if (e instanceof Error) {
258
- return UNAUTHORIZED(e.message);
259
- }
260
- throw e;
261
- }
262
- };
263
-
264
- // src/auth/handlers/logout.ts
265
- var logoutHandler = async (request, { authService }) => {
266
- const auth = await authService.verifyOrRefresh(request);
267
- if (!auth) {
268
- return UNAUTHORIZED();
269
- }
270
- await authService.authRepository.updateUserRefreshToken(auth.userId, null);
271
- const type = new URL(request.url).searchParams.get("type");
272
- if (type === "json") {
273
- return NO_CONTENT();
274
- }
275
- const headers = new Headers();
276
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
277
- authService.getAccessTokenSetCookie(null),
278
- authService.getRefreshTokenSetCookie(null)
279
- ]);
280
- headers.append("Set-Cookie", accessTokenSetCookie);
281
- headers.append("Set-Cookie", refreshTokenSetCookie);
282
- return NO_CONTENT({
283
- headers
284
- });
285
- };
286
-
287
- // src/auth/handlers/refresh.ts
288
- var refreshHandler = async (request, {
289
- authService
290
- }) => {
291
- const refreshToken = request?.headers.get("Authorization")?.replace("Bearer ", "") || await authService.getRefreshTokenFromCookies(request);
292
- if (!refreshToken) {
293
- return BAD_REQUEST();
294
- }
295
- try {
296
- const accessToken = await authService.refreshAccessToken(refreshToken);
297
- return CREATED({ accessToken });
298
- } catch (e) {
299
- if (e instanceof Error) {
300
- return UNAUTHORIZED(e.message);
301
- }
302
- throw e;
303
- }
304
- };
305
-
306
- // src/auth/handlers/signup.ts
307
- var import_uuid = require("uuid");
308
- var bcrypt = __toESM(require("bcryptjs"));
309
- var signupHandler = async (request, {
310
- authService,
311
- fileRepository
312
- }) => {
313
- const body = await request.json();
314
- const {
315
- email,
316
- password,
317
- passwordConfirm,
318
- name,
319
- profileImageId
320
- } = body;
321
- if (!email) {
322
- return BAD_REQUEST("\uC774\uBA54\uC77C\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
323
- }
324
- if (!password) {
325
- return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694.");
326
- }
327
- if (!passwordConfirm) {
328
- return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638 \uD655\uC778\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.");
329
- }
330
- const existing = await authService.authRepository.findCredentialById(email);
331
- if (existing) {
332
- return CONFLICT("\uC774\uBBF8 \uAC00\uC785\uD55C \uC774\uBA54\uC77C\uC785\uB2C8\uB2E4.");
333
- }
334
- if (password !== passwordConfirm) {
335
- return BAD_REQUEST("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.");
336
- }
337
- const profileImage = profileImageId ? await fileRepository.findFileById(profileImageId) : void 0;
338
- const userId = (0, import_uuid.v5)(email, import_uuid.v5.DNS);
339
- const user = await authService.authRepository.createUser({
340
- id: userId,
341
- name,
342
- role: "user",
343
- email,
344
- profileImage
345
- });
346
- await authService.authRepository.createCredential({
347
- id: email,
348
- userId,
349
- password: bcrypt.hashSync(password, 10)
350
- });
351
- const { accessToken, refreshToken } = await authService.issueTokenPair(user);
352
- const searchParams = new URL(request.url).searchParams;
353
- const type = searchParams.get("type");
354
- if (type === "json") {
355
- return CREATED({ accessToken, refreshToken });
356
- }
357
- const [accessTokenSetCookie, refreshTokenSetCookie] = await Promise.all([
358
- authService.getAccessTokenSetCookie(accessToken),
359
- authService.getRefreshTokenSetCookie(refreshToken)
360
- ]);
361
- const payload = authService.jwtManager.decode(accessToken);
362
- const headers = new Headers();
363
- headers.append("Set-Cookie", accessTokenSetCookie);
364
- headers.append("Set-Cookie", refreshTokenSetCookie);
365
- return CREATED(payload, {
366
- headers
367
- });
368
- };
369
-
370
- // src/auth/handlers/signup_with_thirdparty.ts
371
- var import_uuid2 = require("uuid");
372
- var signUpWithThirdpartyHandler = async (request, {
373
- authService,
374
- fileService,
375
- signupTokenSecret
376
- }) => {
377
- const body = await request.json();
378
- const {
379
- token
380
- } = body;
381
- const payload = await authService.jwtManager.verify(token, signupTokenSecret);
382
- const { provider, id: thirdpartyId, email, name, picture } = payload;
383
- const existing = await authService.authRepository.findThirdPartyAuth(
384
- provider,
385
- thirdpartyId
386
- );
387
- if (existing) {
388
- return CONFLICT("\uC774\uBBF8 \uAC00\uC785\uB41C \uC81C3\uC790 \uC778\uC99D \uC815\uBCF4\uC785\uB2C8\uB2E4.");
389
- }
390
- const userId = (0, import_uuid2.v5)(thirdpartyId, import_uuid2.v5.DNS);
391
- const profileImage = await (async () => {
392
- if (!picture) {
393
- return;
394
- }
395
- const arrayBuffer = await fetch(picture).then((res) => res.arrayBuffer());
396
- const { file } = await fileService.putFile(Buffer.from(arrayBuffer), {
397
- userId,
398
- name: "profile.jpg",
399
- type: "image/jpeg",
400
- size: arrayBuffer.byteLength
401
- });
402
- return file;
403
- })();
404
- const user = await authService.authRepository.createUser({
405
- id: userId,
406
- name,
407
- role: "user",
408
- email,
409
- profileImage
410
- });
411
- await authService.authRepository.createThirdPartyAuth({
412
- id: thirdpartyId,
413
- provider,
414
- userId
415
- });
416
- const { accessToken, refreshToken } = await authService.issueTokenPair(user);
417
- return CREATED({ accessToken, refreshToken });
418
- };
419
-
420
- // src/auth/handlers/request_password_reset.ts
421
- var requestPasswordResetHandler = async (request, {
422
- passwordRecoveryService
423
- }) => {
424
- const { email } = await request.json();
425
- try {
426
- await passwordRecoveryService.requestPasswordReset(email);
427
- return CREATED({ message: "\uBE44\uBC00\uBC88\uD638 \uC7AC\uC124\uC815 \uC774\uBA54\uC77C\uC744 \uC804\uC1A1\uD588\uC2B5\uB2C8\uB2E4." });
428
- } catch (error) {
429
- console.error(error);
430
- return INTERNAL_SERVER_ERROR("\uC774\uBA54\uC77C \uC804\uC1A1\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
431
- }
432
- };
433
-
434
- // src/auth/handlers/reset_password.ts
435
- var resetPasswordHandler = async (request, {
436
- passwordRecoveryService
437
- }) => {
438
- const { token, password, passwordConfirm } = await request.json();
439
- await passwordRecoveryService.resetPassword(token, password, passwordConfirm);
440
- return NO_CONTENT();
441
- };
442
-
443
- // src/route/api.ts
444
- var createAPIHandler = ({
445
- authService,
446
- fileService,
447
- passwordRecoveryService,
448
- getThirdPartyAuth,
449
- signupTokenSecret
450
- }) => {
451
- const handler = async ({ request, params }) => {
452
- const method = request.method.toUpperCase();
453
- const slug = params["*"] ? params["*"].split("/") : [];
454
- switch (slug[0]) {
455
- case "auth": {
456
- switch (slug[1]) {
457
- case void 0: {
458
- switch (method) {
459
- case "GET": {
460
- return findAuthHandler(request, { authService });
461
- }
462
- }
463
- }
464
- case "login": {
465
- switch (slug[2]) {
466
- case void 0: {
467
- switch (method) {
468
- case "POST": {
469
- return loginHandler(request, {
470
- authService
471
- });
472
- }
473
- }
474
- }
475
- default: {
476
- const provider = slug[2];
477
- switch (method) {
478
- case "POST": {
479
- return loginWithThirdPartyHandler(
480
- request,
481
- { provider, getThirdPartyAuth }
482
- );
483
- }
484
- }
485
- }
486
- }
487
- }
488
- case "logout": {
489
- switch (method) {
490
- case "POST": {
491
- return logoutHandler(request, {
492
- authService
493
- });
494
- }
495
- }
496
- }
497
- case "refresh": {
498
- switch (method) {
499
- case "GET": {
500
- return refreshHandler(request, { authService });
501
- }
502
- }
503
- }
504
- case "signup": {
505
- switch (slug[2]) {
506
- case void 0: {
507
- switch (method) {
508
- case "POST": {
509
- return signupHandler(request, {
510
- authService,
511
- fileRepository: fileService.fileRepository
512
- });
513
- }
514
- }
515
- }
516
- default: {
517
- switch (method) {
518
- case "POST": {
519
- return signUpWithThirdpartyHandler(
520
- request,
521
- { authService, fileService, signupTokenSecret }
522
- );
523
- }
524
- }
525
- }
526
- }
527
- }
528
- case "callback": {
529
- if (slug[2]) {
530
- const provider = slug[2];
531
- if (method === "GET") {
532
- return thirdpartyAuthCallbackHandler(
533
- request,
534
- {
535
- provider,
536
- authService,
537
- getThirdPartyAuth
538
- }
539
- );
540
- }
541
- }
542
- }
543
- case "request-password-reset": {
544
- return requestPasswordResetHandler(request, { passwordRecoveryService });
545
- }
546
- case "reset-password": {
547
- return resetPasswordHandler(request, { passwordRecoveryService });
548
- }
549
- }
550
- }
551
- case "files": {
552
- switch (slug[1]) {
553
- case void 0: {
554
- switch (method) {
555
- case "POST": {
556
- return uploadFileHandler(request, { authService, fileService });
557
- }
558
- }
559
- }
560
- default: {
561
- switch (method) {
562
- case "DELETE": {
563
- const fileId = slug[1];
564
- return deleteFileHandler(
565
- request,
566
- { fileId },
567
- { authService, fileRepository: fileService.fileRepository }
568
- );
569
- }
570
- }
571
- }
572
- }
573
- }
574
- default: {
575
- return NOT_FOUND();
576
- }
577
- }
578
- };
579
- return handler;
580
- };
581
- // Annotate the CommonJS export names for ESM import in node:
582
- 0 && (module.exports = {
583
- createAPIHandler
584
- });