Skip to content

Type Alias: JSONRPCServiceEntrypointOptions ​

JSONRPCServiceEntrypointOptions = JSONRPCMappingOptions & object

The options of jsonRPCServiceEntrypoint: its transport, and how the requests map to the service actions (see JSONRPCMappingOptions).

Type Declaration ​

end? ​

optional end?: "application" | "none" | (() => void | Promise<void>)

What happens when the stdio input ends (the parent process is gone): 'application' exits the application with the code 0 once the requests in progress are answered, 'none' does nothing, or a function run once they are answered.

Default ​

ts
'application'

framing? ​

optional framing?: "newline" | "content-length"

How the messages are delimited on stdio: 'newline' (one JSON message per line), or 'content-length' (each message after a Content-Length header and a blank line, as in the Language Server Protocol). The responses and the notifications are written the same way.

Default ​

ts
'newline'

heartbeat? ​

optional heartbeat?: number

The interval between the pings of the WebSocket connections, in milliseconds; 0 sends none. A connection that has not answered a ping by the next one is terminated.

Default ​

ts
30000

host? ​

optional host?: string

The host or address of the HTTP or WebSocket server.

Default ​

ts
all the interfaces

input? ​

optional input?: Readable

The stream the stdio transport reads.

Default ​

ts
process.stdin

limit? ​

optional limit?: number

The largest message, in bytes. Over HTTP a larger body is answered with 413; over WebSocket the connection is closed by ws; over stdio a larger message is skipped (the rest of its line, or the length its header declares) and answered with an Invalid Request error without id (-32600).

Default ​

ts
10485760 (10 MiB)

listening? ​

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

Run once the HTTP or WebSocket server listens, with the server (to read the port picked for port 0). A failure fails the entrypoint start. Not called with stdio.

Parameters ​

server ​

Server

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.

output? ​

optional output?: Writable

The stream the stdio transport writes.

Default ​

ts
process.stdout

path? ​

optional path?: string

The path receiving the requests (HTTP) or the connections (WebSocket).

Default ​

ts
'/'

port? ​

optional port?: number

The port of the HTTP or WebSocket server; 0 picks a random free port. The entrypoint fails to start when the port is in use.

Default ​

ts
3000

transport? ​

optional transport?: "http" | "websocket" | "stdio"

The transport of the messages: 'http' (a POST per message), 'websocket' (a message per WebSocket text frame, with the events pushed; it needs the optional package ws), or 'stdio' (the process's standard input and output, for a child process, with the events pushed). With 'stdio', the standard output belongs to the protocol: the application's logs must be written to the standard error ({class: Logger, destinations: [process.stderr]}), or they corrupt the messages.

Default ​

ts
'http'

Released under the MIT License.