/
websocket.ts
62 lines (56 loc) · 2.22 KB
/
websocket.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
55
56
57
58
59
60
61
62
// Note that to use the websocket server, you also need the web server enabled
import { ActionheroConfigInterface } from "..";
const namespace = "websocket";
declare module ".." {
export interface ActionheroConfigInterface {
[namespace]: ReturnType<typeof DEFAULT[typeof namespace]>;
}
}
export const DEFAULT = {
[namespace]: (config: ActionheroConfigInterface) => {
return {
enabled: true,
// you can pass a FQDN (like https://company.com) here or 'window.location.origin'
clientUrl: "window.location.origin",
// Directory to render client-side JS.
// Path should start with "/" and will be built starting from api.config..general.paths.public
clientJsPath: "javascript/",
// the name of the client-side JS file to render. Both `.js` and `.min.js` versions will be created
// do not include the file extension
// set to `undefined` to not render the client-side JS on boot
clientJsName: "ActionheroWebsocketClient",
// should the server signal clients to not reconnect when the server is shutdown/reboot
destroyClientsOnShutdown: false,
// websocket Server Options:
server: {
// authorization: null,
// pathname: '/primus',
// parser: 'JSON',
// transformer: 'websockets',
// plugin: {},
// timeout: 35000,
// origins: '*',
// methods: ['GET','HEAD','PUT','POST','DELETE','OPTIONS'],
// credentials: true,
// maxAge: '30 days',
// exposed: false,
},
// websocket Client Options:
client: {
apiPath: "/api", // the api base endpoint on your actionhero server
// the cookie name we should use for shared authentication between WS and web connections
cookieKey: config.web.fingerprintOptions.cookieKey,
// reconnect: {},
// timeout: 10000,
// ping: 25000,
// pong: 10000,
// strategy: "online",
// manual: false,
// websockets: true,
// network: true,
// transport: {},
// queueSize: Infinity,
},
};
},
};