@thestarweb/star-framework-app-web 1.2.5 → 1.3.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/CHANGELOG.md +46 -0
- package/dist/abort-signal/browser.js +2 -2
- package/dist/abort-signal/browser.js.map +1 -1
- package/dist/abort-signal/index.js +3 -3
- package/dist/abort-signal/index.js.map +1 -1
- package/dist/abort-signal/server.js +4 -3
- package/dist/abort-signal/server.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/cli/dev-server.js +1 -1
- package/dist/cli/dev-server.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/interceptor/index.js +5 -4
- package/dist/interceptor/index.js.map +1 -1
- package/dist/interceptor/middleware-to-interceptor/index.js +1 -1
- package/dist/interceptor/middleware-to-interceptor/index.js.map +1 -1
- package/dist/params/index.js +1 -0
- package/dist/params/index.js.map +1 -1
- package/dist/request/index.js +2 -2
- package/dist/request/index.js.map +1 -1
- package/dist/request/server.js +2 -2
- package/dist/request/server.js.map +1 -1
- package/dist/request/types.js +5 -4
- package/dist/request/types.js.map +1 -1
- package/dist/route/index.js +7 -3
- package/dist/route/index.js.map +1 -1
- package/dist/server/body/helper.js +1 -1
- package/dist/server/body/helper.js.map +1 -1
- package/dist/server/dump-api-type.js +1 -1
- package/dist/server/dump-api-type.js.map +1 -1
- package/dist/server/index.js +8 -5
- package/dist/server/index.js.map +1 -1
- package/dist/view/data-context/context.js +9 -6
- package/dist/view/data-context/context.js.map +1 -1
- package/dist/view/data-context/index.js +1 -1
- package/dist/view/html/create-element.js +2 -2
- package/dist/view/html/create-element.js.map +1 -1
- package/dist/view/html/parse-html-to-v-dom.js +1 -1
- package/dist/view/html/parse-html-to-v-dom.js.map +1 -1
- package/dist/view/html/render-v-dom-to-string.js +3 -3
- package/dist/view/html/render-v-dom-to-string.js.map +1 -1
- package/dist/view/layout.js +6 -4
- package/dist/view/layout.js.map +1 -1
- package/dist/view/render/render.js +5 -3
- package/dist/view/render/render.js.map +1 -1
- package/dist/view/types.js +1 -1
- package/dist/view/utils/find-route-dom.js +1 -1
- package/dist/view/utils/find-route-dom.js.map +1 -1
- package/dist/view/utils/get-render/client.js +10 -6
- package/dist/view/utils/get-render/client.js.map +1 -1
- package/dist/view/utils/get-render/common.js +6 -6
- package/dist/view/utils/get-render/common.js.map +1 -1
- package/dist/view/utils/get-render/server.js +26 -1
- package/dist/view/utils/get-render/server.js.map +1 -1
- package/dist/view/utils/remove-prefix.js +8 -0
- package/dist/view/utils/remove-prefix.js.map +1 -0
- package/dist/view/view.js +1 -1
- package/dist/view/view.js.map +1 -1
- package/package.json +10 -7
- package/resource/base-style.css +27 -27
- package/resource/default-index.html +10 -10
- package/src/cli-helper.ts +5 -5
- package/src/interceptor/index.ts +26 -26
- package/src/interceptor/middleware-to-interceptor/index.ts +29 -29
- package/src/interceptor/middleware-to-interceptor/mock-res.ts +255 -255
- package/src/interceptor/middleware-to-interceptor/mook-req.ts +218 -218
- package/src/interceptor/types.ts +7 -7
- package/src/params/index.ts +1 -0
- package/src/request/server.ts +2 -2
- package/src/request/types.ts +6 -5
- package/src/return-types/index.ts +2 -2
- package/src/return-types/location-to.ts +8 -8
- package/src/return-types/response-with-meta.ts +17 -17
- package/src/route/index.ts +43 -43
- package/src/route/types.ts +11 -11
- package/src/server/body/helper.ts +110 -110
- package/src/server/body/json.ts +217 -217
- package/src/server/body/types.ts +6 -6
- package/src/server/index.ts +8 -2
- package/src/server/types.ts +11 -11
- package/src/view/const.ts +2 -2
- package/src/view/data-context/index.ts +18 -18
- package/src/view/html/index.ts +3 -3
- package/src/view/html/render-v-dom-to-string.ts +79 -79
- package/src/view/html/types.ts +32 -32
- package/src/view/index.ts +6 -6
- package/src/view/render/html-render.ts +21 -21
- package/src/view/render/index.ts +2 -2
- package/src/view/types.ts +1 -1
- package/src/view/utils/find-route-dom.ts +19 -19
- package/src/view/utils/get-render/client.ts +9 -3
- package/src/view/utils/get-render/common.ts +2 -2
- package/src/view/utils/get-render/server.ts +34 -1
- package/src/view/utils/index.ts +2 -2
- package/src/view/utils/loading-progress.ts +58 -58
- package/src/view/utils/remove-prefix.ts +5 -0
- package/dist/runtime/index.js +0 -84
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/type.js +0 -11
- package/dist/runtime/type.js.map +0 -1
- package/dist/server/utils/pass-through-readable.js +0 -13
- package/dist/server/utils/pass-through-readable.js.map +0 -1
- package/dist/view/data-context/conetext.js +0 -70
- package/dist/view/data-context/conetext.js.map +0 -1
|
@@ -1,218 +1,218 @@
|
|
|
1
|
-
import { IncomingHttpHeaders } from "node:http";
|
|
2
|
-
import {
|
|
3
|
-
Duplex,
|
|
4
|
-
PipeOptions,
|
|
5
|
-
Readable,
|
|
6
|
-
ReadableIteratorOptions,
|
|
7
|
-
ReadableOperatorOptions,
|
|
8
|
-
} from "node:stream";
|
|
9
|
-
import { CallProp } from "../../server/types.js";
|
|
10
|
-
import { Abortable } from "node:events";
|
|
11
|
-
import { ByteReadableStream } from "node:stream/iter";
|
|
12
|
-
import { WritableStream, TransformStream } from "node:stream/web";
|
|
13
|
-
|
|
14
|
-
export class MookReq {
|
|
15
|
-
constructor(req: CallProp) {
|
|
16
|
-
this.headers = req.header;
|
|
17
|
-
this.headersDistinct = req.header;
|
|
18
|
-
this.rawHeaders = [];
|
|
19
|
-
this.url = req.url.pathname + req.url.search;
|
|
20
|
-
this.method = req.method;
|
|
21
|
-
}
|
|
22
|
-
destroy(error?: Error): this {
|
|
23
|
-
throw new Error("Method not implemented.");
|
|
24
|
-
}
|
|
25
|
-
addListener(eventName: unknown, listener: unknown): this {
|
|
26
|
-
throw new Error("Method not implemented.");
|
|
27
|
-
}
|
|
28
|
-
emit(eventName: unknown, ...args: unknown[]): boolean {
|
|
29
|
-
throw new Error("Method not implemented.");
|
|
30
|
-
}
|
|
31
|
-
listenerCount(eventName: unknown, listener?: unknown): number {
|
|
32
|
-
throw new Error("Method not implemented.");
|
|
33
|
-
}
|
|
34
|
-
listeners(eventName: unknown) {
|
|
35
|
-
throw new Error("Method not implemented.");
|
|
36
|
-
}
|
|
37
|
-
off(eventName: unknown, listener: unknown): this {
|
|
38
|
-
throw new Error("Method not implemented.");
|
|
39
|
-
}
|
|
40
|
-
on(eventName: unknown, listener: unknown): this {
|
|
41
|
-
throw new Error("Method not implemented.");
|
|
42
|
-
}
|
|
43
|
-
once(eventName: unknown, listener: unknown): this {
|
|
44
|
-
throw new Error("Method not implemented.");
|
|
45
|
-
}
|
|
46
|
-
prependListener(eventName: unknown, listener: unknown): this {
|
|
47
|
-
throw new Error("Method not implemented.");
|
|
48
|
-
}
|
|
49
|
-
prependOnceListener(eventName: unknown, listener: unknown): this {
|
|
50
|
-
throw new Error("Method not implemented.");
|
|
51
|
-
}
|
|
52
|
-
rawListeners(eventName: unknown) {
|
|
53
|
-
throw new Error("Method not implemented.");
|
|
54
|
-
}
|
|
55
|
-
removeAllListeners(eventName?: unknown): this {
|
|
56
|
-
throw new Error("Method not implemented.");
|
|
57
|
-
}
|
|
58
|
-
removeListener(eventName: unknown, listener: unknown): this {
|
|
59
|
-
throw new Error("Method not implemented.");
|
|
60
|
-
}
|
|
61
|
-
readableAborted = false;
|
|
62
|
-
readable = false;
|
|
63
|
-
readableDidRead = true;
|
|
64
|
-
readableEncoding = null;
|
|
65
|
-
readableEnded = true;
|
|
66
|
-
readableFlowing = false;
|
|
67
|
-
readableHighWaterMark = 16 * 1024;
|
|
68
|
-
readableLength = 0;
|
|
69
|
-
readableObjectMode = false;
|
|
70
|
-
destroyed = false;
|
|
71
|
-
closed = false;
|
|
72
|
-
errored = null;
|
|
73
|
-
_construct?(callback: (error?: Error | null) => void): void {
|
|
74
|
-
throw new Error("Method not implemented.");
|
|
75
|
-
}
|
|
76
|
-
_read(size: number): void {
|
|
77
|
-
throw new Error("Method not implemented.");
|
|
78
|
-
}
|
|
79
|
-
read(size?: number) {
|
|
80
|
-
throw new Error("Method not implemented.");
|
|
81
|
-
}
|
|
82
|
-
setEncoding(encoding: BufferEncoding): this {
|
|
83
|
-
throw new Error("Method not implemented.");
|
|
84
|
-
}
|
|
85
|
-
pause(): this {
|
|
86
|
-
throw new Error("Method not implemented.");
|
|
87
|
-
}
|
|
88
|
-
resume(): this {
|
|
89
|
-
throw new Error("Method not implemented.");
|
|
90
|
-
}
|
|
91
|
-
isPaused(): boolean {
|
|
92
|
-
throw new Error("Method not implemented.");
|
|
93
|
-
}
|
|
94
|
-
unpipe(destination?: NodeJS.WritableStream): this {
|
|
95
|
-
throw new Error("Method not implemented.");
|
|
96
|
-
}
|
|
97
|
-
unshift(chunk: any, encoding?: BufferEncoding): void {
|
|
98
|
-
throw new Error("Method not implemented.");
|
|
99
|
-
}
|
|
100
|
-
wrap(stream: NodeJS.ReadableStream): this {
|
|
101
|
-
throw new Error("Method not implemented.");
|
|
102
|
-
}
|
|
103
|
-
push(chunk: any, encoding?: BufferEncoding): boolean {
|
|
104
|
-
throw new Error("Method not implemented.");
|
|
105
|
-
}
|
|
106
|
-
compose(
|
|
107
|
-
stream:
|
|
108
|
-
| NodeJS.WritableStream
|
|
109
|
-
| WritableStream
|
|
110
|
-
| TransformStream
|
|
111
|
-
| ((source: any) => void),
|
|
112
|
-
options?: Abortable,
|
|
113
|
-
): Duplex {
|
|
114
|
-
throw new Error("Method not implemented.");
|
|
115
|
-
}
|
|
116
|
-
iterator(options?: ReadableIteratorOptions): NodeJS.AsyncIterator<any> {
|
|
117
|
-
throw new Error("Method not implemented.");
|
|
118
|
-
}
|
|
119
|
-
map(
|
|
120
|
-
fn: (data: any, options?: Abortable) => any,
|
|
121
|
-
options?: ReadableOperatorOptions,
|
|
122
|
-
): Readable {
|
|
123
|
-
throw new Error("Method not implemented.");
|
|
124
|
-
}
|
|
125
|
-
filter(
|
|
126
|
-
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
127
|
-
options?: ReadableOperatorOptions,
|
|
128
|
-
): Readable {
|
|
129
|
-
throw new Error("Method not implemented.");
|
|
130
|
-
}
|
|
131
|
-
forEach(
|
|
132
|
-
fn: (data: any, options?: Abortable) => void | Promise<void>,
|
|
133
|
-
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
134
|
-
): Promise<void> {
|
|
135
|
-
throw new Error("Method not implemented.");
|
|
136
|
-
}
|
|
137
|
-
toArray(options?: Abortable): Promise<any[]> {
|
|
138
|
-
throw new Error("Method not implemented.");
|
|
139
|
-
}
|
|
140
|
-
some(
|
|
141
|
-
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
142
|
-
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
143
|
-
): Promise<boolean> {
|
|
144
|
-
throw new Error("Method not implemented.");
|
|
145
|
-
}
|
|
146
|
-
find(fn: unknown, options?: unknown) {
|
|
147
|
-
throw new Error("Method not implemented.");
|
|
148
|
-
}
|
|
149
|
-
every(
|
|
150
|
-
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
151
|
-
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
152
|
-
): Promise<boolean> {
|
|
153
|
-
throw new Error("Method not implemented.");
|
|
154
|
-
}
|
|
155
|
-
flatMap(
|
|
156
|
-
fn: (data: any, options?: Abortable) => any,
|
|
157
|
-
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
158
|
-
): Readable {
|
|
159
|
-
throw new Error("Method not implemented.");
|
|
160
|
-
}
|
|
161
|
-
drop(limit: number, options?: Abortable): Readable {
|
|
162
|
-
throw new Error("Method not implemented.");
|
|
163
|
-
}
|
|
164
|
-
take(limit: number, options?: Abortable): Readable {
|
|
165
|
-
throw new Error("Method not implemented.");
|
|
166
|
-
}
|
|
167
|
-
reduce(fn: unknown, initial?: unknown, options?: unknown): any {
|
|
168
|
-
throw new Error("Method not implemented.");
|
|
169
|
-
}
|
|
170
|
-
_destroy(
|
|
171
|
-
error: Error | null,
|
|
172
|
-
callback: (error?: Error | null) => void,
|
|
173
|
-
): void {
|
|
174
|
-
throw new Error("Method not implemented.");
|
|
175
|
-
}
|
|
176
|
-
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any> {
|
|
177
|
-
throw new Error("Method not implemented.");
|
|
178
|
-
}
|
|
179
|
-
[Symbol.asyncDispose](): Promise<void> {
|
|
180
|
-
throw new Error("Method not implemented.");
|
|
181
|
-
}
|
|
182
|
-
pipe<T extends NodeJS.WritableStream>(
|
|
183
|
-
destination: T,
|
|
184
|
-
options?: PipeOptions,
|
|
185
|
-
): T {
|
|
186
|
-
throw new Error("Method not implemented.");
|
|
187
|
-
}
|
|
188
|
-
eventNames(): (string | symbol)[] {
|
|
189
|
-
throw new Error("Method not implemented.");
|
|
190
|
-
}
|
|
191
|
-
getMaxListeners(): number {
|
|
192
|
-
throw new Error("Method not implemented.");
|
|
193
|
-
}
|
|
194
|
-
setMaxListeners(n: number): this {
|
|
195
|
-
throw new Error("Method not implemented.");
|
|
196
|
-
}
|
|
197
|
-
aborted = false;
|
|
198
|
-
httpVersion = "1.1";
|
|
199
|
-
httpVersionMajor = 1;
|
|
200
|
-
httpVersionMinor = 1;
|
|
201
|
-
complete = false;
|
|
202
|
-
connection = null as any;
|
|
203
|
-
socket = null as any;
|
|
204
|
-
headers: IncomingHttpHeaders;
|
|
205
|
-
headersDistinct: NodeJS.Dict<string[]>;
|
|
206
|
-
rawHeaders: string[];
|
|
207
|
-
trailers: NodeJS.Dict<string> = {};
|
|
208
|
-
trailersDistinct = {};
|
|
209
|
-
rawTrailers = [];
|
|
210
|
-
setTimeout(msecs: number, callback?: () => void): this {
|
|
211
|
-
throw new Error("Method not implemented.");
|
|
212
|
-
}
|
|
213
|
-
signal: AbortSignal = null as any;
|
|
214
|
-
method?: string | undefined;
|
|
215
|
-
url?: string | undefined;
|
|
216
|
-
statusCode?: number | undefined;
|
|
217
|
-
statusMessage?: string | undefined;
|
|
218
|
-
}
|
|
1
|
+
import { IncomingHttpHeaders } from "node:http";
|
|
2
|
+
import {
|
|
3
|
+
Duplex,
|
|
4
|
+
PipeOptions,
|
|
5
|
+
Readable,
|
|
6
|
+
ReadableIteratorOptions,
|
|
7
|
+
ReadableOperatorOptions,
|
|
8
|
+
} from "node:stream";
|
|
9
|
+
import { CallProp } from "../../server/types.js";
|
|
10
|
+
import { Abortable } from "node:events";
|
|
11
|
+
import { ByteReadableStream } from "node:stream/iter";
|
|
12
|
+
import { WritableStream, TransformStream } from "node:stream/web";
|
|
13
|
+
|
|
14
|
+
export class MookReq {
|
|
15
|
+
constructor(req: CallProp) {
|
|
16
|
+
this.headers = req.header;
|
|
17
|
+
this.headersDistinct = req.header;
|
|
18
|
+
this.rawHeaders = [];
|
|
19
|
+
this.url = req.url.pathname + req.url.search;
|
|
20
|
+
this.method = req.method;
|
|
21
|
+
}
|
|
22
|
+
destroy(error?: Error): this {
|
|
23
|
+
throw new Error("Method not implemented.");
|
|
24
|
+
}
|
|
25
|
+
addListener(eventName: unknown, listener: unknown): this {
|
|
26
|
+
throw new Error("Method not implemented.");
|
|
27
|
+
}
|
|
28
|
+
emit(eventName: unknown, ...args: unknown[]): boolean {
|
|
29
|
+
throw new Error("Method not implemented.");
|
|
30
|
+
}
|
|
31
|
+
listenerCount(eventName: unknown, listener?: unknown): number {
|
|
32
|
+
throw new Error("Method not implemented.");
|
|
33
|
+
}
|
|
34
|
+
listeners(eventName: unknown) {
|
|
35
|
+
throw new Error("Method not implemented.");
|
|
36
|
+
}
|
|
37
|
+
off(eventName: unknown, listener: unknown): this {
|
|
38
|
+
throw new Error("Method not implemented.");
|
|
39
|
+
}
|
|
40
|
+
on(eventName: unknown, listener: unknown): this {
|
|
41
|
+
throw new Error("Method not implemented.");
|
|
42
|
+
}
|
|
43
|
+
once(eventName: unknown, listener: unknown): this {
|
|
44
|
+
throw new Error("Method not implemented.");
|
|
45
|
+
}
|
|
46
|
+
prependListener(eventName: unknown, listener: unknown): this {
|
|
47
|
+
throw new Error("Method not implemented.");
|
|
48
|
+
}
|
|
49
|
+
prependOnceListener(eventName: unknown, listener: unknown): this {
|
|
50
|
+
throw new Error("Method not implemented.");
|
|
51
|
+
}
|
|
52
|
+
rawListeners(eventName: unknown) {
|
|
53
|
+
throw new Error("Method not implemented.");
|
|
54
|
+
}
|
|
55
|
+
removeAllListeners(eventName?: unknown): this {
|
|
56
|
+
throw new Error("Method not implemented.");
|
|
57
|
+
}
|
|
58
|
+
removeListener(eventName: unknown, listener: unknown): this {
|
|
59
|
+
throw new Error("Method not implemented.");
|
|
60
|
+
}
|
|
61
|
+
readableAborted = false;
|
|
62
|
+
readable = false;
|
|
63
|
+
readableDidRead = true;
|
|
64
|
+
readableEncoding = null;
|
|
65
|
+
readableEnded = true;
|
|
66
|
+
readableFlowing = false;
|
|
67
|
+
readableHighWaterMark = 16 * 1024;
|
|
68
|
+
readableLength = 0;
|
|
69
|
+
readableObjectMode = false;
|
|
70
|
+
destroyed = false;
|
|
71
|
+
closed = false;
|
|
72
|
+
errored = null;
|
|
73
|
+
_construct?(callback: (error?: Error | null) => void): void {
|
|
74
|
+
throw new Error("Method not implemented.");
|
|
75
|
+
}
|
|
76
|
+
_read(size: number): void {
|
|
77
|
+
throw new Error("Method not implemented.");
|
|
78
|
+
}
|
|
79
|
+
read(size?: number) {
|
|
80
|
+
throw new Error("Method not implemented.");
|
|
81
|
+
}
|
|
82
|
+
setEncoding(encoding: BufferEncoding): this {
|
|
83
|
+
throw new Error("Method not implemented.");
|
|
84
|
+
}
|
|
85
|
+
pause(): this {
|
|
86
|
+
throw new Error("Method not implemented.");
|
|
87
|
+
}
|
|
88
|
+
resume(): this {
|
|
89
|
+
throw new Error("Method not implemented.");
|
|
90
|
+
}
|
|
91
|
+
isPaused(): boolean {
|
|
92
|
+
throw new Error("Method not implemented.");
|
|
93
|
+
}
|
|
94
|
+
unpipe(destination?: NodeJS.WritableStream): this {
|
|
95
|
+
throw new Error("Method not implemented.");
|
|
96
|
+
}
|
|
97
|
+
unshift(chunk: any, encoding?: BufferEncoding): void {
|
|
98
|
+
throw new Error("Method not implemented.");
|
|
99
|
+
}
|
|
100
|
+
wrap(stream: NodeJS.ReadableStream): this {
|
|
101
|
+
throw new Error("Method not implemented.");
|
|
102
|
+
}
|
|
103
|
+
push(chunk: any, encoding?: BufferEncoding): boolean {
|
|
104
|
+
throw new Error("Method not implemented.");
|
|
105
|
+
}
|
|
106
|
+
compose(
|
|
107
|
+
stream:
|
|
108
|
+
| NodeJS.WritableStream
|
|
109
|
+
| WritableStream
|
|
110
|
+
| TransformStream
|
|
111
|
+
| ((source: any) => void),
|
|
112
|
+
options?: Abortable,
|
|
113
|
+
): Duplex {
|
|
114
|
+
throw new Error("Method not implemented.");
|
|
115
|
+
}
|
|
116
|
+
iterator(options?: ReadableIteratorOptions): NodeJS.AsyncIterator<any> {
|
|
117
|
+
throw new Error("Method not implemented.");
|
|
118
|
+
}
|
|
119
|
+
map(
|
|
120
|
+
fn: (data: any, options?: Abortable) => any,
|
|
121
|
+
options?: ReadableOperatorOptions,
|
|
122
|
+
): Readable {
|
|
123
|
+
throw new Error("Method not implemented.");
|
|
124
|
+
}
|
|
125
|
+
filter(
|
|
126
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
127
|
+
options?: ReadableOperatorOptions,
|
|
128
|
+
): Readable {
|
|
129
|
+
throw new Error("Method not implemented.");
|
|
130
|
+
}
|
|
131
|
+
forEach(
|
|
132
|
+
fn: (data: any, options?: Abortable) => void | Promise<void>,
|
|
133
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
134
|
+
): Promise<void> {
|
|
135
|
+
throw new Error("Method not implemented.");
|
|
136
|
+
}
|
|
137
|
+
toArray(options?: Abortable): Promise<any[]> {
|
|
138
|
+
throw new Error("Method not implemented.");
|
|
139
|
+
}
|
|
140
|
+
some(
|
|
141
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
142
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
143
|
+
): Promise<boolean> {
|
|
144
|
+
throw new Error("Method not implemented.");
|
|
145
|
+
}
|
|
146
|
+
find(fn: unknown, options?: unknown) {
|
|
147
|
+
throw new Error("Method not implemented.");
|
|
148
|
+
}
|
|
149
|
+
every(
|
|
150
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
151
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
152
|
+
): Promise<boolean> {
|
|
153
|
+
throw new Error("Method not implemented.");
|
|
154
|
+
}
|
|
155
|
+
flatMap(
|
|
156
|
+
fn: (data: any, options?: Abortable) => any,
|
|
157
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
158
|
+
): Readable {
|
|
159
|
+
throw new Error("Method not implemented.");
|
|
160
|
+
}
|
|
161
|
+
drop(limit: number, options?: Abortable): Readable {
|
|
162
|
+
throw new Error("Method not implemented.");
|
|
163
|
+
}
|
|
164
|
+
take(limit: number, options?: Abortable): Readable {
|
|
165
|
+
throw new Error("Method not implemented.");
|
|
166
|
+
}
|
|
167
|
+
reduce(fn: unknown, initial?: unknown, options?: unknown): any {
|
|
168
|
+
throw new Error("Method not implemented.");
|
|
169
|
+
}
|
|
170
|
+
_destroy(
|
|
171
|
+
error: Error | null,
|
|
172
|
+
callback: (error?: Error | null) => void,
|
|
173
|
+
): void {
|
|
174
|
+
throw new Error("Method not implemented.");
|
|
175
|
+
}
|
|
176
|
+
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any> {
|
|
177
|
+
throw new Error("Method not implemented.");
|
|
178
|
+
}
|
|
179
|
+
[Symbol.asyncDispose](): Promise<void> {
|
|
180
|
+
throw new Error("Method not implemented.");
|
|
181
|
+
}
|
|
182
|
+
pipe<T extends NodeJS.WritableStream>(
|
|
183
|
+
destination: T,
|
|
184
|
+
options?: PipeOptions,
|
|
185
|
+
): T {
|
|
186
|
+
throw new Error("Method not implemented.");
|
|
187
|
+
}
|
|
188
|
+
eventNames(): (string | symbol)[] {
|
|
189
|
+
throw new Error("Method not implemented.");
|
|
190
|
+
}
|
|
191
|
+
getMaxListeners(): number {
|
|
192
|
+
throw new Error("Method not implemented.");
|
|
193
|
+
}
|
|
194
|
+
setMaxListeners(n: number): this {
|
|
195
|
+
throw new Error("Method not implemented.");
|
|
196
|
+
}
|
|
197
|
+
aborted = false;
|
|
198
|
+
httpVersion = "1.1";
|
|
199
|
+
httpVersionMajor = 1;
|
|
200
|
+
httpVersionMinor = 1;
|
|
201
|
+
complete = false;
|
|
202
|
+
connection = null as any;
|
|
203
|
+
socket = null as any;
|
|
204
|
+
headers: IncomingHttpHeaders;
|
|
205
|
+
headersDistinct: NodeJS.Dict<string[]>;
|
|
206
|
+
rawHeaders: string[];
|
|
207
|
+
trailers: NodeJS.Dict<string> = {};
|
|
208
|
+
trailersDistinct = {};
|
|
209
|
+
rawTrailers = [];
|
|
210
|
+
setTimeout(msecs: number, callback?: () => void): this {
|
|
211
|
+
throw new Error("Method not implemented.");
|
|
212
|
+
}
|
|
213
|
+
signal: AbortSignal = null as any;
|
|
214
|
+
method?: string | undefined;
|
|
215
|
+
url?: string | undefined;
|
|
216
|
+
statusCode?: number | undefined;
|
|
217
|
+
statusMessage?: string | undefined;
|
|
218
|
+
}
|
package/src/interceptor/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ResponseWithMeta } from "../return-types/response-with-meta.js";
|
|
2
|
-
import { CallProp } from "../server/types.js";
|
|
3
|
-
|
|
4
|
-
export type Interceptor = (
|
|
5
|
-
req: CallProp,
|
|
6
|
-
next: (req: CallProp) => ResponseWithMeta | Promise<ResponseWithMeta>,
|
|
7
|
-
) => ResponseWithMeta | Promise<ResponseWithMeta>;
|
|
1
|
+
import { ResponseWithMeta } from "../return-types/response-with-meta.js";
|
|
2
|
+
import { CallProp } from "../server/types.js";
|
|
3
|
+
|
|
4
|
+
export type Interceptor = (
|
|
5
|
+
req: CallProp,
|
|
6
|
+
next: (req: CallProp) => ResponseWithMeta | Promise<ResponseWithMeta>,
|
|
7
|
+
) => ResponseWithMeta | Promise<ResponseWithMeta>;
|
package/src/params/index.ts
CHANGED
|
@@ -15,3 +15,4 @@ export const Query = paramMeta.createDecorator("query");
|
|
|
15
15
|
export const Param = paramMeta.createDecorator("param");
|
|
16
16
|
export const Context = paramMeta.createDecorator("context");
|
|
17
17
|
export const Ip = () => Context("ip");
|
|
18
|
+
export const Prefix = () => Context("prefix");
|
package/src/request/server.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class ServerSideRequest extends SFWebRequest {
|
|
|
28
28
|
method,
|
|
29
29
|
url,
|
|
30
30
|
header: prop.header || {},
|
|
31
|
-
context: {},
|
|
31
|
+
context: { prefix: "/" },
|
|
32
32
|
appName: app,
|
|
33
33
|
body: new ReadableStream({
|
|
34
34
|
start(ctrl) {
|
|
@@ -39,7 +39,7 @@ export class ServerSideRequest extends SFWebRequest {
|
|
|
39
39
|
},
|
|
40
40
|
}),
|
|
41
41
|
signal: signal || new AbortController().signal,
|
|
42
|
-
ip:
|
|
42
|
+
ip: "127.0.0.1",
|
|
43
43
|
port: 0,
|
|
44
44
|
});
|
|
45
45
|
const reader = res.data?.getReader();
|
package/src/request/types.ts
CHANGED
|
@@ -79,7 +79,8 @@ export abstract class SFWebRequest<
|
|
|
79
79
|
path: string,
|
|
80
80
|
prop: UserProp,
|
|
81
81
|
): Promise<any> {
|
|
82
|
-
const
|
|
82
|
+
const index = path.indexOf(":/");
|
|
83
|
+
const service = path.substring(0, index);
|
|
83
84
|
if (!prop.header) prop.header = {};
|
|
84
85
|
if (!prop.header["content-type"])
|
|
85
86
|
prop.header["content-type"] = "application/json";
|
|
@@ -87,15 +88,15 @@ export abstract class SFWebRequest<
|
|
|
87
88
|
let signal = prop.keepRequest ? undefined : getRequestAbortSignal();
|
|
88
89
|
if (prop.signal)
|
|
89
90
|
signal = signal ? mergeAbortSignal(signal, prop.signal) : prop.signal;
|
|
90
|
-
const data = await (
|
|
91
|
-
? fetch(
|
|
91
|
+
const data = await (service === "https" || service === "http"
|
|
92
|
+
? fetch(path, {
|
|
92
93
|
...prop,
|
|
93
94
|
body,
|
|
94
95
|
})
|
|
95
96
|
: this.handleInnerCall(
|
|
96
|
-
|
|
97
|
+
service,
|
|
97
98
|
method,
|
|
98
|
-
|
|
99
|
+
new URL(path.substring(index + 2), "sf-inner-call:/"),
|
|
99
100
|
signal,
|
|
100
101
|
{ ...prop, body },
|
|
101
102
|
));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./response-with-meta.js";
|
|
2
|
-
export * from "./location-to.js";
|
|
1
|
+
export * from "./response-with-meta.js";
|
|
2
|
+
export * from "./location-to.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { redirectStatusCode } from "../view/const.js";
|
|
2
|
-
import { ResponseWithMeta } from "./response-with-meta.js";
|
|
3
|
-
|
|
4
|
-
export class LocationTo extends ResponseWithMeta {
|
|
5
|
-
constructor(path: string, code: (typeof redirectStatusCode)[number] = 302) {
|
|
6
|
-
super(undefined, { code, header: { Location: path } });
|
|
7
|
-
}
|
|
8
|
-
}
|
|
1
|
+
import { redirectStatusCode } from "../view/const.js";
|
|
2
|
+
import { ResponseWithMeta } from "./response-with-meta.js";
|
|
3
|
+
|
|
4
|
+
export class LocationTo extends ResponseWithMeta {
|
|
5
|
+
constructor(path: string, code: (typeof redirectStatusCode)[number] = 302) {
|
|
6
|
+
super(undefined, { code, header: { Location: path } });
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export class ResponseWithMeta {
|
|
2
|
-
code?: number;
|
|
3
|
-
header?: Record<string, string | string[]>;
|
|
4
|
-
data: any;
|
|
5
|
-
constructor(data: any, meta?: Partial<Omit<ResponseWithMeta, "data">>) {
|
|
6
|
-
Object.assign(this, meta);
|
|
7
|
-
this.data = data;
|
|
8
|
-
this.__ResponseWithMetaFlag = ResponseWithMeta.__ResponseWithMetaFlag;
|
|
9
|
-
Object.freeze(this);
|
|
10
|
-
}
|
|
11
|
-
public readonly __ResponseWithMetaFlag: string;
|
|
12
|
-
private static readonly __ResponseWithMetaFlag = "ResponseWithMeta";
|
|
13
|
-
static isResponseWithMeta(data: any): data is ResponseWithMeta {
|
|
14
|
-
if (!data || typeof data !== "object") return false;
|
|
15
|
-
return data.__ResponseWithMetaFlag === this.__ResponseWithMetaFlag;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
1
|
+
export class ResponseWithMeta {
|
|
2
|
+
code?: number;
|
|
3
|
+
header?: Record<string, string | string[]>;
|
|
4
|
+
data: any;
|
|
5
|
+
constructor(data: any, meta?: Partial<Omit<ResponseWithMeta, "data">>) {
|
|
6
|
+
Object.assign(this, meta);
|
|
7
|
+
this.data = data;
|
|
8
|
+
this.__ResponseWithMetaFlag = ResponseWithMeta.__ResponseWithMetaFlag;
|
|
9
|
+
Object.freeze(this);
|
|
10
|
+
}
|
|
11
|
+
public readonly __ResponseWithMetaFlag: string;
|
|
12
|
+
private static readonly __ResponseWithMetaFlag = "ResponseWithMeta";
|
|
13
|
+
static isResponseWithMeta(data: any): data is ResponseWithMeta {
|
|
14
|
+
if (!data || typeof data !== "object") return false;
|
|
15
|
+
return data.__ResponseWithMetaFlag === this.__ResponseWithMetaFlag;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/route/index.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RouteMetadata,
|
|
3
|
-
type RouteMetadataRouteType,
|
|
4
|
-
} from "@thestarweb/star-framework-route";
|
|
5
|
-
import {
|
|
6
|
-
CommonRouteOption,
|
|
7
|
-
DeleteRouteOption,
|
|
8
|
-
GetRouteOption,
|
|
9
|
-
Method,
|
|
10
|
-
PostRouteOption,
|
|
11
|
-
PutRouteOption,
|
|
12
|
-
SubRouteOption,
|
|
13
|
-
} from "./types.js";
|
|
14
|
-
|
|
15
|
-
const routeMetadata = new RouteMetadata<
|
|
16
|
-
Method,
|
|
17
|
-
CommonRouteOption,
|
|
18
|
-
{
|
|
19
|
-
POST: PostRouteOption;
|
|
20
|
-
GET: GetRouteOption;
|
|
21
|
-
PUT: PutRouteOption;
|
|
22
|
-
DELETE: DeleteRouteOption;
|
|
23
|
-
},
|
|
24
|
-
SubRouteOption
|
|
25
|
-
>("web");
|
|
26
|
-
export type RouteType<M extends Method> = RouteMetadataRouteType<
|
|
27
|
-
typeof routeMetadata,
|
|
28
|
-
M
|
|
29
|
-
>;
|
|
30
|
-
|
|
31
|
-
export const Get = routeMetadata.route("GET");
|
|
32
|
-
export const Post = routeMetadata.route("POST");
|
|
33
|
-
export const Put = routeMetadata.route("PUT");
|
|
34
|
-
export const Delete = routeMetadata.route("DELETE");
|
|
35
|
-
export const SubRoute = routeMetadata.subRoute.bind(routeMetadata);
|
|
36
|
-
|
|
37
|
-
export function getFlatRoute(obj: object) {
|
|
38
|
-
return routeMetadata.routeFinderFlat(obj);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function parseRoute(obj: object) {
|
|
42
|
-
return routeMetadata.parse(obj);
|
|
43
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
RouteMetadata,
|
|
3
|
+
type RouteMetadataRouteType,
|
|
4
|
+
} from "@thestarweb/star-framework-route";
|
|
5
|
+
import {
|
|
6
|
+
CommonRouteOption,
|
|
7
|
+
DeleteRouteOption,
|
|
8
|
+
GetRouteOption,
|
|
9
|
+
Method,
|
|
10
|
+
PostRouteOption,
|
|
11
|
+
PutRouteOption,
|
|
12
|
+
SubRouteOption,
|
|
13
|
+
} from "./types.js";
|
|
14
|
+
|
|
15
|
+
const routeMetadata = new RouteMetadata<
|
|
16
|
+
Method,
|
|
17
|
+
CommonRouteOption,
|
|
18
|
+
{
|
|
19
|
+
POST: PostRouteOption;
|
|
20
|
+
GET: GetRouteOption;
|
|
21
|
+
PUT: PutRouteOption;
|
|
22
|
+
DELETE: DeleteRouteOption;
|
|
23
|
+
},
|
|
24
|
+
SubRouteOption
|
|
25
|
+
>("web");
|
|
26
|
+
export type RouteType<M extends Method> = RouteMetadataRouteType<
|
|
27
|
+
typeof routeMetadata,
|
|
28
|
+
M
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
export const Get = routeMetadata.route("GET");
|
|
32
|
+
export const Post = routeMetadata.route("POST");
|
|
33
|
+
export const Put = routeMetadata.route("PUT");
|
|
34
|
+
export const Delete = routeMetadata.route("DELETE");
|
|
35
|
+
export const SubRoute = routeMetadata.subRoute.bind(routeMetadata);
|
|
36
|
+
|
|
37
|
+
export function getFlatRoute(obj: object) {
|
|
38
|
+
return routeMetadata.routeFinderFlat(obj);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function parseRoute(obj: object) {
|
|
42
|
+
return routeMetadata.parse(obj);
|
|
43
|
+
}
|