@esportsplus/routing 0.0.8 → 0.0.10

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.

Potentially problematic release.


This version of @esportsplus/routing might be problematic. Click here for more details.

Files changed (65) hide show
  1. package/build/hash.d.ts +70 -0
  2. package/build/hash.js +75 -0
  3. package/build/index.d.ts +6 -92
  4. package/build/index.js +6 -8
  5. package/build/middleware/dispatch.d.ts +5 -0
  6. package/build/middleware/dispatch.js +7 -0
  7. package/build/middleware/factory.d.ts +3 -3
  8. package/build/middleware/factory.js +13 -13
  9. package/build/middleware/index.d.ts +24 -47
  10. package/build/middleware/index.js +5 -4
  11. package/build/middleware/match.d.ts +10 -0
  12. package/build/middleware/match.js +23 -0
  13. package/build/router/index.d.ts +36 -0
  14. package/build/router/index.js +182 -0
  15. package/build/router/node.d.ts +17 -0
  16. package/build/router/node.js +93 -0
  17. package/build/router/path.d.ts +14 -0
  18. package/build/router/path.js +21 -0
  19. package/build/slugify.d.ts +2 -0
  20. package/build/slugify.js +3 -0
  21. package/build/symbols.d.ts +4 -0
  22. package/build/symbols.js +4 -0
  23. package/build/types.d.ts +12 -26
  24. package/build/types.js +2 -1
  25. package/package.json +2 -3
  26. package/readme.md +1 -0
  27. package/src/hash.ts +106 -0
  28. package/src/index.ts +4 -6
  29. package/src/middleware/dispatch.ts +12 -0
  30. package/src/middleware/factory.ts +10 -9
  31. package/src/middleware/index.ts +4 -3
  32. package/src/middleware/match.ts +41 -0
  33. package/src/router/index.ts +237 -0
  34. package/src/router/node.ts +141 -0
  35. package/src/router/path.ts +29 -0
  36. package/src/slugify.ts +4 -0
  37. package/src/symbols.ts +8 -0
  38. package/src/types.ts +9 -26
  39. package/tsconfig.json +5 -19
  40. package/build/group.d.ts +0 -3
  41. package/build/group.js +0 -8
  42. package/build/listener.d.ts +0 -4
  43. package/build/listener.js +0 -13
  44. package/build/middleware/common/dispatch.d.ts +0 -3
  45. package/build/middleware/common/dispatch.js +0 -11
  46. package/build/middleware/common/index.d.ts +0 -29
  47. package/build/middleware/common/index.js +0 -3
  48. package/build/middleware/common/match.d.ts +0 -3
  49. package/build/middleware/common/match.js +0 -12
  50. package/build/middleware/factory-backup.d.ts +0 -3
  51. package/build/middleware/factory-backup.js +0 -11
  52. package/build/redirect.d.ts +0 -2
  53. package/build/redirect.js +0 -10
  54. package/build/routes.d.ts +0 -20
  55. package/build/routes.js +0 -45
  56. package/build/url.d.ts +0 -30
  57. package/build/url.js +0 -22
  58. package/src/group.ts +0 -11
  59. package/src/listener.ts +0 -24
  60. package/src/middleware/common/dispatch.ts +0 -17
  61. package/src/middleware/common/index.ts +0 -5
  62. package/src/middleware/common/match.ts +0 -24
  63. package/src/redirect.ts +0 -16
  64. package/src/routes.ts +0 -68
  65. package/src/url.ts +0 -30
package/src/routes.ts DELETED
@@ -1,68 +0,0 @@
1
- import { Group, Responder, Routes, Route } from './types';
2
-
3
-
4
- let groups: Group[] = [],
5
- routes: Record<Route['name'], Route> = {},
6
- subdomains: Record<NonNullable<Route['subdomain']>, Record<NonNullable<Route['path']>, Route['name']>> = {};
7
-
8
-
9
- const add = ({ name, path, responder }: { name: string, path?: string, responder: Responder }) => {
10
- let http = path !== undefined,
11
- route: Route = {
12
- middleware: [],
13
- name: '',
14
- responder
15
- };
16
-
17
- if (http) {
18
- route.path = '';
19
- route.subdomain = '';
20
- }
21
-
22
- for (let i = 0, n = groups.length; i < n; i++) {
23
- let group = groups[i];
24
-
25
- if (group.middleware.length) {
26
- route.middleware.push(...group.middleware);
27
- }
28
-
29
- route.name += group.name;
30
-
31
- if (http) {
32
- route.path += group.path;
33
- route.subdomain = group.subdomain + route.subdomain;
34
- }
35
- }
36
-
37
- routes[ route.name += name ] = route;
38
-
39
- if (http) {
40
- route.path = `${route.path}${path}`;
41
-
42
- if (route.path[0] !== '/') {
43
- route.path = `/${route.path}`;
44
- }
45
-
46
- if (!route.subdomain || route.subdomain === 'www') {
47
- route.subdomain = '';
48
- }
49
-
50
- if (!subdomains[route.subdomain]) {
51
- subdomains[route.subdomain] = {};
52
- }
53
-
54
- subdomains[route.subdomain][route.path] = route.name;
55
- }
56
-
57
- return route;
58
- };
59
-
60
- const group = (group: any, fn: (routes: Routes) => void) => {
61
- groups.push(group);
62
- fn({ add, group, routes, subdomains });
63
- groups.pop();
64
- };
65
-
66
-
67
- export default { add, group, routes, subdomains };
68
- export { add, group, routes, subdomains };
package/src/url.ts DELETED
@@ -1,30 +0,0 @@
1
- const parse = (url: string = window?.location?.href || '') => {
2
- let { hash, host, hostname, href, origin, port, protocol } = new URL( url ),
3
- parts = host.split('.'),
4
- path = hash?.replace('#/', '/')?.split('?') || ['/', ''],
5
- subdomain = '';
6
-
7
- if (parts.length > 2) {
8
- subdomain = parts[0];
9
-
10
- if (['127', 'www'].includes(subdomain)) {
11
- subdomain = '';
12
- }
13
- }
14
-
15
- return {
16
- data: {} as Record<string, any>,
17
- href: href,
18
- hostname: hostname,
19
- origin: origin,
20
- path: path[0],
21
- port: port,
22
- protocol: protocol,
23
- query: Object.fromEntries( (new URLSearchParams(path[1])).entries() ),
24
- subdomain
25
- };
26
- };
27
-
28
-
29
- export default { parse };
30
- export { parse };