routup 3.2.0 → 4.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.
- package/dist/adapters/node/module.d.ts +0 -1
- package/dist/constants.d.ts +2 -0
- package/dist/handler/module.d.ts +1 -1
- package/dist/index.cjs +187 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +185 -103
- package/dist/index.mjs.map +1 -1
- package/dist/path/type.d.ts +3 -3
- package/dist/request/helpers/env.d.ts +4 -4
- package/dist/request/helpers/header-accept-encoding.d.ts +0 -1
- package/dist/request/helpers/header.d.ts +0 -1
- package/dist/request/helpers/http2.d.ts +2 -0
- package/dist/request/helpers/index.d.ts +1 -0
- package/dist/request/module.d.ts +0 -1
- package/dist/request/types.d.ts +0 -1
- package/dist/response/helpers/event-stream/factory.d.ts +3 -0
- package/dist/response/helpers/event-stream/index.d.ts +2 -0
- package/dist/response/helpers/event-stream/module.d.ts +17 -0
- package/dist/response/helpers/event-stream/types.d.ts +24 -0
- package/dist/response/helpers/event-stream/utils.d.ts +2 -0
- package/dist/response/helpers/gone.d.ts +1 -0
- package/dist/response/helpers/header.d.ts +0 -1
- package/dist/response/helpers/index.d.ts +1 -0
- package/dist/response/types.d.ts +0 -1
- package/dist/types.d.ts +0 -2
- package/dist/utils/etag/module.d.ts +0 -2
- package/dist/utils/etag/type.d.ts +0 -1
- package/dist/utils/object.d.ts +2 -0
- package/dist/utils/stream.d.ts +0 -2
- package/package.json +23 -23
package/dist/path/type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ParseOptions,
|
|
2
|
-
export type PathMatcherOptions =
|
|
1
|
+
import type { ParseOptions, PathToRegexpOptions } from 'path-to-regexp';
|
|
2
|
+
export type PathMatcherOptions = PathToRegexpOptions & ParseOptions;
|
|
3
3
|
export type PathMatcherExecResult = {
|
|
4
4
|
path: string;
|
|
5
5
|
params: Record<string, any>;
|
|
6
6
|
};
|
|
7
|
-
export type Path = string
|
|
7
|
+
export type Path = string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Request } from '../types';
|
|
2
|
-
export declare function setRequestEnv(req: Request, key: string, value: unknown): void;
|
|
3
|
-
export declare function setRequestEnv(req: Request, record: Record<string, any>, append?: boolean): void;
|
|
2
|
+
export declare function setRequestEnv(req: Request, key: string | symbol, value: unknown): void;
|
|
3
|
+
export declare function setRequestEnv(req: Request, record: Record<string | symbol, any>, append?: boolean): void;
|
|
4
4
|
export declare function useRequestEnv(req: Request): Record<string, any>;
|
|
5
|
-
export declare function useRequestEnv(req: Request, key:
|
|
6
|
-
export declare function unsetRequestEnv(req: Request, key:
|
|
5
|
+
export declare function useRequestEnv(req: Request, key: PropertyKey): unknown | undefined;
|
|
6
|
+
export declare function unsetRequestEnv(req: Request, key: PropertyKey): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { IncomingMessage } from 'node:http';
|
|
3
2
|
export declare function getRequestAcceptableEncodings(req: IncomingMessage): string[];
|
|
4
3
|
export declare function getRequestAcceptableEncoding(req: IncomingMessage, input: string | string[]): string | undefined;
|
|
@@ -7,6 +7,7 @@ export * from './header-accept-encoding';
|
|
|
7
7
|
export * from './header-accept-language';
|
|
8
8
|
export * from './header-content-type';
|
|
9
9
|
export * from './hostname';
|
|
10
|
+
export * from './http2';
|
|
10
11
|
export * from './ip';
|
|
11
12
|
export * from './mount-path';
|
|
12
13
|
export * from './negotiator';
|
package/dist/request/module.d.ts
CHANGED
package/dist/request/types.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PassThrough } from 'readable-stream';
|
|
2
|
+
import type { Response } from '../../types';
|
|
3
|
+
import type { EventStreamListener, EventStreamMessage } from './types';
|
|
4
|
+
export declare class EventStream {
|
|
5
|
+
protected response: Response;
|
|
6
|
+
protected passThrough: PassThrough;
|
|
7
|
+
protected flushed: boolean;
|
|
8
|
+
protected eventHandlers: Record<string, EventStreamListener[]>;
|
|
9
|
+
constructor(response: Response);
|
|
10
|
+
protected open(): void;
|
|
11
|
+
write(message: EventStreamMessage): void;
|
|
12
|
+
write(message: string): void;
|
|
13
|
+
end(): void;
|
|
14
|
+
on(event: 'close', listener: EventStreamListener): void;
|
|
15
|
+
on(event: 'error', listener: EventStreamListener): void;
|
|
16
|
+
protected emit(event: string, ...args: any[]): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
|
|
3
|
+
*/
|
|
4
|
+
export type EventStreamMessage = {
|
|
5
|
+
/**
|
|
6
|
+
* The event ID to set the EventSource object's last event ID value.
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The reconnection time.
|
|
11
|
+
* If the connection to the server is lost, the browser will wait for the specified time before attempting to reconnect.
|
|
12
|
+
* This must be an integer, specifying the reconnection time in milliseconds.
|
|
13
|
+
*/
|
|
14
|
+
retry?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The data field for the message.
|
|
17
|
+
*/
|
|
18
|
+
data: string;
|
|
19
|
+
/**
|
|
20
|
+
* A string identifying the type of event described.
|
|
21
|
+
*/
|
|
22
|
+
event?: string;
|
|
23
|
+
};
|
|
24
|
+
export type EventStreamListener<T = any> = (err: Error | null, data: T) => void | Promise<void>;
|
package/dist/response/types.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/utils/object.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
1
|
export declare function isObject(item: unknown): item is Record<string, any>;
|
|
2
|
+
export declare function setProperty(record: Record<PropertyKey, any>, property: PropertyKey, value: any): void;
|
|
3
|
+
export declare function getProperty<T = any>(req: Record<PropertyKey, any>, property: PropertyKey): T;
|
package/dist/utils/stream.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "routup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Routup is a minimalistic http based routing framework.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -52,35 +52,35 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@ebec/http": "^2.3.0",
|
|
54
54
|
"buffer": "^6.0.3",
|
|
55
|
-
"mime-explorer": "^1.
|
|
55
|
+
"mime-explorer": "^1.1.0",
|
|
56
56
|
"negotiator": "^0.6.3",
|
|
57
|
-
"path-to-regexp": "^
|
|
57
|
+
"path-to-regexp": "^7.0.0",
|
|
58
58
|
"proxy-addr": "^2.0.7",
|
|
59
|
-
"readable-stream": "^4.
|
|
60
|
-
"smob": "^1.
|
|
59
|
+
"readable-stream": "^4.5.2",
|
|
60
|
+
"smob": "^1.5.0",
|
|
61
61
|
"uncrypto": "^0.1.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@rollup/plugin-commonjs": "^
|
|
64
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
65
65
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
66
|
-
"@swc/core": "^1.
|
|
67
|
-
"@swc/jest": "^0.2.
|
|
68
|
-
"@tada5hi/commitlint-config": "^1.1
|
|
69
|
-
"@tada5hi/eslint-config-typescript": "^1.2.
|
|
70
|
-
"@tada5hi/semantic-release": "^0.3.
|
|
71
|
-
"@tada5hi/tsconfig": "^0.5.
|
|
72
|
-
"@types/jest": "^29.5.
|
|
73
|
-
"@types/negotiator": "^0.6.
|
|
74
|
-
"@types/node": "^20.
|
|
75
|
-
"@types/proxy-addr": "^2.0.
|
|
76
|
-
"@types/readable-stream": "^4.0.
|
|
77
|
-
"@types/supertest": "^
|
|
66
|
+
"@swc/core": "^1.6.5",
|
|
67
|
+
"@swc/jest": "^0.2.36",
|
|
68
|
+
"@tada5hi/commitlint-config": "^1.2.1",
|
|
69
|
+
"@tada5hi/eslint-config-typescript": "^1.2.11",
|
|
70
|
+
"@tada5hi/semantic-release": "^0.3.1",
|
|
71
|
+
"@tada5hi/tsconfig": "^0.5.1",
|
|
72
|
+
"@types/jest": "^29.5.12",
|
|
73
|
+
"@types/negotiator": "^0.6.3",
|
|
74
|
+
"@types/node": "^20.12.2",
|
|
75
|
+
"@types/proxy-addr": "^2.0.3",
|
|
76
|
+
"@types/readable-stream": "^4.0.14",
|
|
77
|
+
"@types/supertest": "^6.0.2",
|
|
78
78
|
"cross-env": "^7.0.3",
|
|
79
79
|
"jest": "^29.7.0",
|
|
80
|
-
"rimraf": "^5.0.
|
|
81
|
-
"rollup": "^4.
|
|
82
|
-
"semantic-release": "^22.0.
|
|
83
|
-
"supertest": "^
|
|
84
|
-
"typescript": "5.
|
|
80
|
+
"rimraf": "^5.0.7",
|
|
81
|
+
"rollup": "^4.18.0",
|
|
82
|
+
"semantic-release": "^22.0.12",
|
|
83
|
+
"supertest": "^7.0.0",
|
|
84
|
+
"typescript": "5.5.2"
|
|
85
85
|
}
|
|
86
86
|
}
|