routup 1.0.2 → 2.0.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 (100) hide show
  1. package/README.md +92 -8
  2. package/dist/dispatcher/adapters/index.d.ts +3 -0
  3. package/dist/dispatcher/adapters/node/index.d.ts +1 -0
  4. package/dist/dispatcher/adapters/node/module.d.ts +6 -0
  5. package/dist/dispatcher/adapters/raw/module.d.ts +4 -0
  6. package/dist/dispatcher/adapters/raw/type.d.ts +18 -0
  7. package/dist/dispatcher/adapters/web/index.d.ts +2 -0
  8. package/dist/dispatcher/adapters/web/module.d.ts +5 -0
  9. package/dist/dispatcher/adapters/web/type.d.ts +3 -0
  10. package/dist/dispatcher/index.d.ts +3 -0
  11. package/dist/dispatcher/type.d.ts +30 -0
  12. package/dist/dispatcher/utils.d.ts +4 -0
  13. package/dist/error.d.ts +1 -0
  14. package/dist/index.cjs +1075 -538
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +4 -5
  17. package/dist/index.mjs +1054 -509
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/layer/module.d.ts +5 -4
  20. package/dist/layer/type.d.ts +1 -2
  21. package/dist/layer/utils.d.ts +1 -1
  22. package/dist/path/index.d.ts +1 -0
  23. package/dist/path/matcher.d.ts +1 -2
  24. package/dist/path/type.d.ts +1 -0
  25. package/dist/path/utils.d.ts +2 -0
  26. package/dist/{helpers/request → request/helpers}/body.d.ts +1 -1
  27. package/dist/{helpers/request → request/helpers}/cache.d.ts +1 -1
  28. package/dist/{helpers/request → request/helpers}/cookie.d.ts +1 -1
  29. package/dist/{helpers/request → request/helpers}/env.d.ts +1 -1
  30. package/dist/{helpers/request → request/helpers}/header-accept-charset.d.ts +1 -1
  31. package/dist/{helpers/request → request/helpers}/header-accept-language.d.ts +1 -1
  32. package/dist/{helpers/request → request/helpers}/header-accept.d.ts +1 -1
  33. package/dist/{helpers/request → request/helpers}/header-content-type.d.ts +1 -1
  34. package/dist/{helpers/request → request/helpers}/header.d.ts +1 -1
  35. package/dist/{helpers/request → request/helpers}/hostname.d.ts +1 -1
  36. package/dist/{helpers/request → request/helpers}/index.d.ts +1 -0
  37. package/dist/{helpers/request → request/helpers}/ip.d.ts +1 -1
  38. package/dist/{helpers/request → request/helpers}/mount-path.d.ts +1 -1
  39. package/dist/{helpers/request → request/helpers}/negotiator.d.ts +1 -1
  40. package/dist/{helpers/request → request/helpers}/params.d.ts +1 -1
  41. package/dist/{helpers/request → request/helpers}/path.d.ts +1 -1
  42. package/dist/{helpers/request → request/helpers}/protocol.d.ts +1 -1
  43. package/dist/{helpers/request → request/helpers}/query.d.ts +1 -1
  44. package/dist/request/helpers/router.d.ts +3 -0
  45. package/dist/request/index.d.ts +3 -0
  46. package/dist/request/module.d.ts +4 -0
  47. package/dist/request/types.d.ts +9 -0
  48. package/dist/{helpers/response → response/helpers}/cache.d.ts +1 -1
  49. package/dist/response/helpers/gone.d.ts +2 -0
  50. package/dist/{helpers/response → response/helpers}/header-attachment.d.ts +1 -1
  51. package/dist/{helpers/response → response/helpers}/header-content-type.d.ts +1 -1
  52. package/dist/{helpers/response → response/helpers}/header.d.ts +1 -1
  53. package/dist/{helpers/response → response/helpers}/index.d.ts +3 -0
  54. package/dist/{helpers/response → response/helpers}/send-accepted.d.ts +2 -2
  55. package/dist/{helpers/response → response/helpers}/send-created.d.ts +2 -2
  56. package/dist/response/helpers/send-file.d.ts +17 -0
  57. package/dist/{helpers/response → response/helpers}/send-format.d.ts +1 -1
  58. package/dist/response/helpers/send-redirect.d.ts +2 -0
  59. package/dist/response/helpers/send-stream.d.ts +2 -0
  60. package/dist/response/helpers/send-web-blob.d.ts +2 -0
  61. package/dist/response/helpers/send-web-response.d.ts +2 -0
  62. package/dist/response/helpers/send.d.ts +2 -0
  63. package/dist/response/helpers/utils.d.ts +2 -0
  64. package/dist/response/index.d.ts +2 -0
  65. package/dist/response/module.d.ts +2 -0
  66. package/dist/route/module.d.ts +6 -5
  67. package/dist/route/type.d.ts +1 -1
  68. package/dist/route/utils.d.ts +1 -1
  69. package/dist/router/index.d.ts +0 -1
  70. package/dist/router/module.d.ts +13 -32
  71. package/dist/router/utils.d.ts +1 -0
  72. package/dist/router-options/index.d.ts +2 -0
  73. package/dist/router-options/module.d.ts +4 -0
  74. package/dist/router-options/transform.d.ts +2 -0
  75. package/dist/router-options/type.d.ts +50 -0
  76. package/dist/types.d.ts +19 -0
  77. package/dist/utils/cookie.d.ts +1 -0
  78. package/dist/utils/etag/module.d.ts +4 -3
  79. package/dist/utils/etag/type.d.ts +1 -1
  80. package/dist/utils/header.d.ts +3 -0
  81. package/dist/utils/index.d.ts +4 -1
  82. package/dist/utils/path.d.ts +5 -2
  83. package/dist/utils/stream.d.ts +8 -0
  84. package/dist/utils/web.d.ts +3 -0
  85. package/package.json +17 -16
  86. package/dist/config/module.d.ts +0 -8
  87. package/dist/config/type.d.ts +0 -34
  88. package/dist/handler/index.d.ts +0 -1
  89. package/dist/handler/utils.d.ts +0 -2
  90. package/dist/helpers/index.d.ts +0 -2
  91. package/dist/helpers/response/send-file.d.ts +0 -9
  92. package/dist/helpers/response/send-redirect.d.ts +0 -2
  93. package/dist/helpers/response/send-stream.d.ts +0 -4
  94. package/dist/helpers/response/send.d.ts +0 -2
  95. package/dist/helpers/response/utils.d.ts +0 -3
  96. package/dist/router/type.d.ts +0 -24
  97. package/dist/type.d.ts +0 -24
  98. package/dist/utils/request.d.ts +0 -2
  99. /package/dist/{config → dispatcher/adapters/raw}/index.d.ts +0 -0
  100. /package/dist/{helpers/request → request/helpers}/header-accept-encoding.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routup",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "description": "Routup is a minimalistic http based routing framework.",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -50,35 +50,36 @@
50
50
  },
51
51
  "homepage": "https://github.com/routup/routup#readme",
52
52
  "dependencies": {
53
- "@ebec/http": "^1.1.0",
54
- "continu": "^1.3.2",
53
+ "buffer": "^6.0.3",
55
54
  "mime-explorer": "^1.0.0",
56
55
  "negotiator": "^0.6.3",
57
56
  "path-to-regexp": "^6.2.1",
58
57
  "proxy-addr": "^2.0.7",
58
+ "readable-stream": "^4.4.2",
59
59
  "smob": "^1.4.0",
60
- "zod": "^3.21.4"
60
+ "uncrypto": "^0.1.3"
61
61
  },
62
62
  "devDependencies": {
63
- "@rollup/plugin-commonjs": "^25.0.3",
64
- "@rollup/plugin-node-resolve": "^15.1.0",
65
- "@swc/core": "^1.3.70",
66
- "@swc/jest": "^0.2.26",
67
- "@tada5hi/commitlint-config": "^1.1.0",
68
- "@tada5hi/eslint-config-typescript": "^1.2.2",
63
+ "@rollup/plugin-commonjs": "^25.0.4",
64
+ "@rollup/plugin-node-resolve": "^15.2.1",
65
+ "@swc/core": "^1.3.84",
66
+ "@swc/jest": "^0.2.29",
67
+ "@tada5hi/commitlint-config": "^1.1.1",
68
+ "@tada5hi/eslint-config-typescript": "^1.2.3",
69
69
  "@tada5hi/semantic-release": "^0.2.0",
70
70
  "@tada5hi/tsconfig": "^0.5.0",
71
- "@types/jest": "^29.5.3",
71
+ "@types/jest": "^29.5.4",
72
72
  "@types/negotiator": "^0.6.1",
73
- "@types/node": "^20.4.2",
73
+ "@types/node": "^20.6.0",
74
74
  "@types/proxy-addr": "^2.0.0",
75
+ "@types/readable-stream": "^4.0.2",
75
76
  "@types/supertest": "^2.0.12",
76
77
  "cross-env": "^7.0.3",
77
- "jest": "^29.6.1",
78
+ "jest": "^29.7.0",
78
79
  "rimraf": "^5.0.1",
79
- "rollup": "^3.26.3",
80
- "semantic-release": "^21.0.7",
80
+ "rollup": "^3.29.1",
81
+ "semantic-release": "^21.1.1",
81
82
  "supertest": "^6.3.3",
82
- "typescript": "5.1.6"
83
+ "typescript": "5.2.2"
83
84
  }
84
85
  }
@@ -1,8 +0,0 @@
1
- import type { FlattenObject } from 'continu';
2
- import { Continu } from 'continu';
3
- import type { Options, OptionsInput } from './type';
4
- export declare function buildConfig(): Continu<Options, OptionsInput>;
5
- export declare function useConfig(): Continu<Options, OptionsInput>;
6
- export declare function setConfig(config: Continu<Options, OptionsInput>): void;
7
- export declare function setConfigOption<K extends keyof FlattenObject<OptionsInput>>(key: K, value: FlattenObject<OptionsInput>[K]): Options;
8
- export declare function getConfigOption(key: keyof FlattenObject<OptionsInput>): string | number | import("../utils").EtagFn | import("../utils").TrustProxyFn;
@@ -1,34 +0,0 @@
1
- import type { EtagFn, EtagInput } from '../utils/etag/type';
2
- import type { TrustProxyFn, TrustProxyInput } from '../utils/trust-proxy';
3
- export type Options = {
4
- /**
5
- * default: production
6
- */
7
- env: string;
8
- /**
9
- * default: () => true
10
- */
11
- etag: EtagFn;
12
- /**
13
- * default: 2
14
- */
15
- subdomainOffset: number;
16
- /**
17
- * default: () => false
18
- */
19
- trustProxy: TrustProxyFn;
20
- /**
21
- * default: 0
22
- */
23
- proxyIpMax: number;
24
- };
25
- export type OptionsInput = {
26
- /**
27
- * default: true
28
- */
29
- etag?: EtagInput;
30
- /**
31
- * default: false
32
- */
33
- trustProxy?: TrustProxyInput;
34
- } & Partial<Omit<Options, 'etag' | 'trustProxy'>>;
@@ -1 +0,0 @@
1
- export * from './utils';
@@ -1,2 +0,0 @@
1
- import type { Next, Response } from '../type';
2
- export declare function processHandlerExecutionOutput(res: Response, next: Next, output?: unknown): void;
@@ -1,2 +0,0 @@
1
- export * from './request';
2
- export * from './response';
@@ -1,9 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Stats } from 'node:fs';
3
- import type { Response } from '../../type';
4
- export type SendFileOptions = {
5
- stats?: Stats;
6
- filePath: string;
7
- attachment?: boolean;
8
- };
9
- export declare function sendFile(res: Response, filePath: string | SendFileOptions, fn?: CallableFunction): void;
@@ -1,2 +0,0 @@
1
- import type { Response } from '../../type';
2
- export declare function sendRedirect(res: Response, location: string, statusCode?: number): void;
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Readable } from 'node:stream';
3
- import type { Response } from '../../type';
4
- export declare function sendStream(res: Response, stream: Readable, fn?: CallableFunction): void;
@@ -1,2 +0,0 @@
1
- import type { Response } from '../../type';
2
- export declare function send(res: Response, chunk?: any): void;
@@ -1,3 +0,0 @@
1
- import type { Response } from '../../type';
2
- export declare function setResponseContentTypeByFileName(res: Response, fileName: string): void;
3
- export declare function onResponseFinished(res: Response, cb: (err?: Error) => void): void;
@@ -1,24 +0,0 @@
1
- import type { PathMatcherOptions } from '../path';
2
- import type { Path } from '../type';
3
- export type RouterOptions = {
4
- /**
5
- * The path the router is mounted on.
6
- *
7
- * @type string
8
- * @default '/'
9
- */
10
- path?: Path;
11
- /**
12
- * Path matcher options.
13
- *
14
- * @default: {end: false, sensitive: true}
15
- */
16
- pathMatcher?: PathMatcherOptions;
17
- /**
18
- * Milliseconds (ms) until the request should be canceled.
19
- *
20
- * @type number
21
- * @default undefined
22
- */
23
- timeout?: number;
24
- };
package/dist/type.d.ts DELETED
@@ -1,24 +0,0 @@
1
- /// <reference types="node" />
2
- import type { IncomingMessage, ServerResponse } from 'node:http';
3
- export interface Response extends ServerResponse {
4
- }
5
- export interface Request extends IncomingMessage {
6
- }
7
- export type Next = (err?: Error) => void;
8
- export type Handler = (req: Request, res: Response, next: Next) => unknown;
9
- export type ErrorHandler = (err: Error, req: Request, res: Response, next: Next) => unknown;
10
- export type Path = string | RegExp;
11
- export type DispatcherMeta = {
12
- /**
13
- * Params collected on path.
14
- */
15
- params?: Record<string, any>;
16
- /**
17
- * Path to check for the current instance.
18
- */
19
- path?: string;
20
- /**
21
- * The relative path on which the router is hung.
22
- */
23
- mountPath?: string;
24
- };
@@ -1,2 +0,0 @@
1
- import type { Next, Response } from '../type';
2
- export declare function createRequestTimeout(res: Response, timeout: number, done?: Next): void;