Skip to content

Type Alias: SocketIOServiceEntrypointOptions ​

SocketIOServiceEntrypointOptions = object

The options of socketIOServiceEntrypoint.

Properties ​

event? ​

optional event?: string

The socket.io event carrying the requests: socket.emit('message', {cmd: 'echo', …}, (response) => …).

Default ​

ts
'message'

host? ​

optional host?: string

The host or address of the adapter's own server.

Default ​

ts
all the interfaces

io? ​

optional io?: SocketIOServer

An existing socket.io server to serve the requests on, used as is: the adapter neither makes it listen nor closes it, and ignores server, port, host and options.

Default ​

ts
a socket.io server created by the adapter

listening? ​

optional listening?: (io, server) => void | Promise<void>

Run once the adapter is ready, with the socket.io server and its HTTP server (undefined when io is given without server). A failure fails the entrypoint start.

Parameters ​

io ​

SocketIOServer

server ​

Server | undefined

Returns ​

void | Promise<void>


middlewares? ​

optional middlewares?: MiddlewareDefinition[]

The middlewares of this adapter's actions, run after the entrypoint's global middlewares.


name? ​

optional name?: string

The adapter name, to tell apart several service adapters of one entrypoint.


namespace? ​

optional namespace?: string

The socket.io namespace receiving the requests.

Default ​

ts
'/'

options? ​

optional options?: Partial<ServerOptions>

The options of the socket.io server created by the adapter (path, cors, transports…).


port? ​

optional port?: number

The port of the adapter's own server (without server and io); 0 picks a random free port. The entrypoint fails to start when the port is in use.

Default ​

ts
3000

server? ​

optional server?: Server | (() => Server)

An HTTP server to attach the socket.io server to (such as the one of expressHTTPEntrypoint, given to its before hook), or a function returning it when the adapter starts. The adapter then does not listen itself, and when it stops it disconnects the sockets but leaves the HTTP server to its owner.

Default ​

a server of its own, listening on port

Released under the MIT License.