-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtype.ts
54 lines (44 loc) · 1.05 KB
/
type.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Server, WebSocket, ServerOptions } from 'ws'
import { Server as httpServer } from 'http'
import { Application } from 'express'
import { IncomingMessage } from "http"
export interface wsIncomingMessage extends IncomingMessage {
/**
* Parse parameters in path, /books/:id => {id: '...'}
*/
params: {
[key: string]: undefined | string,
},
/**
* Parse query parameters, Arrays are not currently supported
*/
query: {
[key: string]: undefined | string,
},
}
export type WsMid = ((ws: WebSocket, req: wsIncomingMessage) => void)
export interface wsRouteItem {
/**
* Route parameter, it can be in the form of /books/:id, array is not supported yet.
*/
route: string,
/**
* new Server({ noServer: true })
*/
wss: Server,
/**
* your websocket api handler
*/
mid: WsMid,
}
export interface wsApplication extends Application {
ws: (route: string, mid: WsMid) => void;
}
export type Arg0Full = {
app: Application,
server: httpServer,
options?: {
ws: ServerOptions
},
}
export type Arg0 = Application | Arg0Full