node-stomp-protocol icon indicating copy to clipboard operation
node-stomp-protocol copied to clipboard

More specific types

Open sywka opened this issue 7 years ago • 2 comments

Description

Why is StompHeaders an optional argument in all methods? By specification in many methods, headings are REQUIRED.

So, it is probably better to make the REQUIRED headers for the api (with compatibility with older versions of the protocol), and also specify the types for each type of message.

For example SEND:

interface StompSendHeaders extends StompHeaders {
  destination: string;
  transaction?: string;
}

public send(headers: StompSendHeaders, body?: string): void {
    console.log("Send!", body, headers);
  }

Versions

node-stomp-protocol: 0.3.8

sywka avatar Sep 19 '18 13:09 sywka

This is a good point for an improvement. Feel free to submit a PR.

pcan avatar Sep 22 '18 09:09 pcan

Just published v0.4.0. This version includes a first breaking change that makes all StompHeaders params mandatory. There should have been an exception for DISCONNECT frame, that hasn't mandatory headers, except when you need to send back a receipt ID, but in order to keep a cleaner and uniform API, it also needs (maybe empty) headers.

pcan avatar Oct 05 '18 11:10 pcan