@rsbuild/core 0.7.0-beta.8 → 0.7.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.
@@ -0,0 +1,90 @@
1
+ /// <reference types="node" />
2
+ import * as http from 'http';
3
+
4
+ /**
5
+ * Create a new connect server.
6
+ */
7
+ declare function createServer(): createServer.Server;
8
+
9
+ declare namespace createServer {
10
+ export type ServerHandle = HandleFunction | http.Server;
11
+
12
+ export class IncomingMessage extends http.IncomingMessage {
13
+ originalUrl?: http.IncomingMessage["url"] | undefined;
14
+ }
15
+
16
+ type NextFunction = (err?: any) => void;
17
+
18
+ export type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void;
19
+ export type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
20
+ export type ErrorHandleFunction = (
21
+ err: any,
22
+ req: IncomingMessage,
23
+ res: http.ServerResponse,
24
+ next: NextFunction,
25
+ ) => void;
26
+ export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
27
+
28
+ export interface ServerStackItem {
29
+ route: string;
30
+ handle: ServerHandle;
31
+ }
32
+
33
+ export interface Server extends NodeJS.EventEmitter {
34
+ (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
35
+
36
+ route: string;
37
+ stack: ServerStackItem[];
38
+
39
+ /**
40
+ * Utilize the given middleware `handle` to the given `route`,
41
+ * defaulting to _/_. This "route" is the mount-point for the
42
+ * middleware, when given a value other than _/_ the middleware
43
+ * is only effective when that segment is present in the request's
44
+ * pathname.
45
+ *
46
+ * For example if we were to mount a function at _/admin_, it would
47
+ * be invoked on _/admin_, and _/admin/settings_, however it would
48
+ * not be invoked for _/_, or _/posts_.
49
+ */
50
+ use(fn: NextHandleFunction): Server;
51
+ use(fn: HandleFunction): Server;
52
+ use(route: string, fn: NextHandleFunction): Server;
53
+ use(route: string, fn: HandleFunction): Server;
54
+
55
+ /**
56
+ * Handle server requests, punting them down
57
+ * the middleware stack.
58
+ */
59
+ handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
60
+
61
+ /**
62
+ * Listen for connections.
63
+ *
64
+ * This method takes the same arguments
65
+ * as node's `http.Server#listen()`.
66
+ *
67
+ * HTTP and HTTPS:
68
+ *
69
+ * If you run your application both as HTTP
70
+ * and HTTPS you may wrap them individually,
71
+ * since your Connect "server" is really just
72
+ * a JavaScript `Function`.
73
+ *
74
+ * var connect = require('connect')
75
+ * , http = require('http')
76
+ * , https = require('https');
77
+ *
78
+ * var app = connect();
79
+ *
80
+ * http.createServer(app).listen(80);
81
+ * https.createServer(options, app).listen(443);
82
+ */
83
+ listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
84
+ listen(port: number, hostname?: string, callback?: Function): http.Server;
85
+ listen(path: string, callback?: Function): http.Server;
86
+ listen(handle: any, listeningListener?: Function): http.Server;
87
+ }
88
+ }
89
+
90
+ export { createServer as default };