@miqro/core 1.3.5 → 1.3.11

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 (171) hide show
  1. package/README.md +81 -253
  2. package/dist/handler/api-router-utils.d.ts +13 -2
  3. package/dist/handler/api-router-utils.js +86 -1
  4. package/dist/handler/api-router-utils.js.map +1 -1
  5. package/dist/handler/api-router.d.ts +29 -2
  6. package/dist/handler/api-router.js +2 -2
  7. package/dist/handler/api-router.js.map +1 -1
  8. package/dist/handler/app.d.ts +4 -9
  9. package/dist/handler/app.js +10 -9
  10. package/dist/handler/app.js.map +1 -1
  11. package/dist/handler/common/context.d.ts +3 -11
  12. package/dist/handler/common/context.js +18 -13
  13. package/dist/handler/common/context.js.map +1 -1
  14. package/dist/handler/common/router-utils.d.ts +18 -10
  15. package/dist/handler/common/router-utils.js +97 -15
  16. package/dist/handler/common/router-utils.js.map +1 -1
  17. package/dist/handler/common/router.d.ts +18 -8
  18. package/dist/handler/common/router.js +12 -1
  19. package/dist/handler/common/router.js.map +1 -1
  20. package/dist/handler/index.d.ts +0 -3
  21. package/dist/handler/index.js +0 -3
  22. package/dist/handler/index.js.map +1 -1
  23. package/dist/handler/middleware/cookie.js +2 -2
  24. package/dist/handler/middleware/cookie.js.map +1 -1
  25. package/dist/handler/middleware/form.js +7 -1
  26. package/dist/handler/middleware/form.js.map +1 -1
  27. package/dist/handler/middleware/group.js +44 -2
  28. package/dist/handler/middleware/group.js.map +1 -1
  29. package/dist/handler/middleware/index.js +2 -6
  30. package/dist/handler/middleware/index.js.map +1 -1
  31. package/dist/handler/middleware/json.js +8 -2
  32. package/dist/handler/middleware/json.js.map +1 -1
  33. package/dist/handler/middleware/text.js +8 -1
  34. package/dist/handler/middleware/text.js.map +1 -1
  35. package/dist/handler/proxy.d.ts +2 -5
  36. package/dist/handler/proxy.js +2 -3
  37. package/dist/handler/proxy.js.map +1 -1
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.js +1 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/{util/test → test/common}/app.d.ts +2 -2
  42. package/dist/{util/test → test/common}/app.js +3 -2
  43. package/dist/test/common/app.js.map +1 -0
  44. package/dist/{util/test → test/common}/common.d.ts +0 -0
  45. package/dist/{util/test → test/common}/common.js +0 -0
  46. package/dist/test/common/common.js.map +1 -0
  47. package/dist/{util/test → test/common}/index.d.ts +1 -0
  48. package/dist/{util/test → test/common}/index.js +1 -0
  49. package/dist/test/common/index.js.map +1 -0
  50. package/dist/test/common/runner.d.ts +28 -0
  51. package/dist/test/common/runner.js +88 -0
  52. package/dist/test/common/runner.js.map +1 -0
  53. package/dist/test/index.d.ts +1 -0
  54. package/dist/{handler/response → test}/index.js +1 -3
  55. package/dist/test/index.js.map +1 -0
  56. package/dist/test/main.d.ts +1 -0
  57. package/dist/test/main.js +31 -0
  58. package/dist/test/main.js.map +1 -0
  59. package/dist/util/cli/index.d.ts +5 -1
  60. package/dist/util/cli/index.js +26 -0
  61. package/dist/util/cli/index.js.map +1 -1
  62. package/dist/util/error/parsererror.d.ts +2 -1
  63. package/dist/util/error/parsererror.js +5 -1
  64. package/dist/util/error/parsererror.js.map +1 -1
  65. package/dist/util/index.d.ts +0 -1
  66. package/dist/util/index.js +0 -3
  67. package/dist/util/index.js.map +1 -1
  68. package/dist/util/loader/index.d.ts +0 -3
  69. package/dist/util/loader/index.js +2 -9
  70. package/dist/util/loader/index.js.map +1 -1
  71. package/dist/util/logger/formatter.js +1 -1
  72. package/dist/util/logger/formatter.js.map +1 -1
  73. package/dist/util/parser/get.js +3 -6
  74. package/dist/util/parser/get.js.map +1 -1
  75. package/dist/util/request/index.d.ts +1 -1
  76. package/dist/util/request/index.js +1 -3
  77. package/dist/util/request/index.js.map +1 -1
  78. package/dist/util/session/common.d.ts +0 -1
  79. package/dist/util/session/common.js +0 -46
  80. package/dist/util/session/common.js.map +1 -1
  81. package/dist/util/session/service.js +2 -2
  82. package/dist/util/session/service.js.map +1 -1
  83. package/package.json +13 -11
  84. package/src/handler/api-router-utils.ts +91 -2
  85. package/src/handler/api-router.ts +30 -4
  86. package/src/handler/app.ts +10 -15
  87. package/src/handler/common/context.ts +19 -24
  88. package/src/handler/common/router-utils.ts +207 -108
  89. package/src/handler/common/router.ts +30 -8
  90. package/src/handler/index.ts +0 -3
  91. package/src/handler/middleware/cookie.ts +12 -12
  92. package/src/handler/middleware/form.ts +8 -2
  93. package/src/handler/middleware/group.ts +44 -2
  94. package/src/handler/middleware/index.ts +0 -4
  95. package/src/handler/middleware/json.ts +9 -3
  96. package/src/handler/middleware/text.ts +8 -1
  97. package/src/handler/proxy.ts +3 -8
  98. package/src/index.ts +1 -0
  99. package/src/{util/test → test/common}/app.ts +6 -5
  100. package/src/{util/test → test/common}/common.ts +0 -0
  101. package/src/{util/test → test/common}/index.ts +1 -0
  102. package/src/test/common/runner.ts +116 -0
  103. package/src/test/index.ts +1 -0
  104. package/src/test/main.ts +32 -0
  105. package/src/util/cli/index.ts +24 -1
  106. package/src/util/error/parsererror.ts +6 -1
  107. package/src/util/index.ts +0 -3
  108. package/src/util/loader/index.ts +1 -7
  109. package/src/util/logger/formatter.ts +1 -1
  110. package/src/util/parser/get.ts +3 -5
  111. package/src/util/request/index.ts +1 -1
  112. package/src/util/session/common.ts +0 -43
  113. package/src/util/session/service.ts +126 -126
  114. package/dist/handler/api-handler.d.ts +0 -29
  115. package/dist/handler/api-handler.js +0 -42
  116. package/dist/handler/api-handler.js.map +0 -1
  117. package/dist/handler/feature-router.d.ts +0 -12
  118. package/dist/handler/feature-router.js +0 -90
  119. package/dist/handler/feature-router.js.map +0 -1
  120. package/dist/handler/response/html.d.ts +0 -10
  121. package/dist/handler/response/html.js +0 -34
  122. package/dist/handler/response/html.js.map +0 -1
  123. package/dist/handler/response/index.d.ts +0 -3
  124. package/dist/handler/response/index.js.map +0 -1
  125. package/dist/handler/response/json.d.ts +0 -2
  126. package/dist/handler/response/json.js +0 -21
  127. package/dist/handler/response/json.js.map +0 -1
  128. package/dist/handler/response/result.d.ts +0 -4
  129. package/dist/handler/response/result.js +0 -46
  130. package/dist/handler/response/result.js.map +0 -1
  131. package/dist/util/cookie/cookie.d.ts +0 -50
  132. package/dist/util/cookie/cookie.js +0 -168
  133. package/dist/util/cookie/cookie.js.map +0 -1
  134. package/dist/util/cookie/index.d.ts +0 -16
  135. package/dist/util/cookie/index.js +0 -9
  136. package/dist/util/cookie/index.js.map +0 -1
  137. package/dist/util/test/app.js.map +0 -1
  138. package/dist/util/test/common.js.map +0 -1
  139. package/dist/util/test/index.js.map +0 -1
  140. package/dist/util/uuid/index.d.ts +0 -7
  141. package/dist/util/uuid/index.js +0 -8
  142. package/dist/util/uuid/index.js.map +0 -1
  143. package/dist/util/uuid/regex.d.ts +0 -2
  144. package/dist/util/uuid/regex.js +0 -5
  145. package/dist/util/uuid/regex.js.map +0 -1
  146. package/dist/util/uuid/rng.d.ts +0 -1
  147. package/dist/util/uuid/rng.js +0 -18
  148. package/dist/util/uuid/rng.js.map +0 -1
  149. package/dist/util/uuid/stringify.d.ts +0 -2
  150. package/dist/util/uuid/stringify.js +0 -50
  151. package/dist/util/uuid/stringify.js.map +0 -1
  152. package/dist/util/uuid/v4.d.ts +0 -5
  153. package/dist/util/uuid/v4.js +0 -27
  154. package/dist/util/uuid/v4.js.map +0 -1
  155. package/dist/util/uuid/validate.d.ts +0 -2
  156. package/dist/util/uuid/validate.js +0 -12
  157. package/dist/util/uuid/validate.js.map +0 -1
  158. package/src/handler/api-handler.ts +0 -55
  159. package/src/handler/feature-router.ts +0 -92
  160. package/src/handler/response/html.ts +0 -36
  161. package/src/handler/response/index.ts +0 -3
  162. package/src/handler/response/json.ts +0 -19
  163. package/src/handler/response/result.ts +0 -40
  164. package/src/util/cookie/cookie.ts +0 -207
  165. package/src/util/cookie/index.ts +0 -6
  166. package/src/util/uuid/index.ts +0 -5
  167. package/src/util/uuid/regex.ts +0 -2
  168. package/src/util/uuid/rng.ts +0 -14
  169. package/src/util/uuid/stringify.ts +0 -53
  170. package/src/util/uuid/v4.ts +0 -30
  171. package/src/util/uuid/validate.ts +0 -8
@@ -1,53 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/stringify.js
2
-
3
- import validate from './validate';
4
-
5
- /**
6
- * Convert array of 16 byte values to UUID string format of the form:
7
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
8
- */
9
- const byteToHex: string[] = [];
10
-
11
- for (let i = 0; i < 256; ++i) {
12
- byteToHex.push((i + 0x100).toString(16).substr(1));
13
- }
14
-
15
- const stringify = (arr: Uint8Array, offset = 0): string => {
16
- // Note: Be careful editing this code! It's been tuned for performance
17
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
18
- const uuid = (
19
- byteToHex[arr[offset + 0]] +
20
- byteToHex[arr[offset + 1]] +
21
- byteToHex[arr[offset + 2]] +
22
- byteToHex[arr[offset + 3]] +
23
- '-' +
24
- byteToHex[arr[offset + 4]] +
25
- byteToHex[arr[offset + 5]] +
26
- '-' +
27
- byteToHex[arr[offset + 6]] +
28
- byteToHex[arr[offset + 7]] +
29
- '-' +
30
- byteToHex[arr[offset + 8]] +
31
- byteToHex[arr[offset + 9]] +
32
- '-' +
33
- byteToHex[arr[offset + 10]] +
34
- byteToHex[arr[offset + 11]] +
35
- byteToHex[arr[offset + 12]] +
36
- byteToHex[arr[offset + 13]] +
37
- byteToHex[arr[offset + 14]] +
38
- byteToHex[arr[offset + 15]]
39
- ).toLowerCase();
40
-
41
- // Consistency check for valid UUID. If this throws, it's likely due to one
42
- // of the following:
43
- // - One or more input array values don't map to a hex octet (leading to
44
- // "undefined" in the uuid)
45
- // - Invalid input values for the RFC `version` or `variant` fields
46
- if (!validate(uuid)) {
47
- throw TypeError('Stringified UUID is invalid');
48
- }
49
-
50
- return uuid;
51
- }
52
-
53
- export default stringify;
@@ -1,30 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/v4.js
2
-
3
- import rng from './rng';
4
- import stringify from './stringify';
5
-
6
- export const v4 = (options?: {
7
- random?: Uint8Array;
8
- rng?: () => Uint8Array;
9
- }, buf?: Buffer, offset?: number) => {
10
- options = options || {};
11
-
12
- const rnds: Uint8Array = options.random || (options.rng || rng)();
13
-
14
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
15
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
16
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
17
-
18
- // Copy bytes to buffer, if provided
19
- if (buf) {
20
- offset = offset || 0;
21
-
22
- for (let i = 0; i < 16; ++i) {
23
- buf[offset + i] = rnds[i];
24
- }
25
-
26
- return buf;
27
- }
28
-
29
- return stringify(rnds);
30
- }
@@ -1,8 +0,0 @@
1
- // https://github.com/uuidjs/uuid/blob/main/src/validate.js
2
- import REGEX from './regex';
3
-
4
- const validate = (uuid: string) => {
5
- return typeof uuid === 'string' && REGEX.test(uuid);
6
- }
7
-
8
- export default validate;