Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): add http and ws inbound transport #392

Conversation

TimoGlastra
Copy link
Contributor

Moves http and ws inbound transports to the node package. I know there's still work to be done on the transports, but this makes it 1000x easier to set up an agent. They're in the node package, so not strictly tied to core

Signed-off-by: Timo Glastra <timo@animo.id>
@TimoGlastra TimoGlastra requested a review from a team as a code owner July 19, 2021 09:21
@TimoGlastra
Copy link
Contributor Author

@karimStekelenburg Once this is merged you can directly use the inbound transports

Copy link
Contributor

@jakubkoci jakubkoci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a good step forward 👍

private logger!: Logger

// We're using a `socketId` just for the prevention of calling the connection handler twice.
private socketIds: Record<string, unknown> = {}

public constructor(socketServer: WebSocket.Server) {
this.socketServer = socketServer
public constructor({ server, port }: { server: Server; port?: undefined } | { server?: undefined; port: number }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it work with the following types?

Suggested change
public constructor({ server, port }: { server: Server; port?: undefined } | { server?: undefined; port: number }) {
public constructor({ server, port }: { server: Server; port?: string } | { server?: Server; port: number }) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want it to be an XOR statement. So either port or server should be provided but not both. If you create the server yourself, you set the port on the server. If you don't create the server yourself, you need to pass the port.

Could probably improve, but this was the easiest way I could think of with explicit typing that you shouldn't provide both

@TimoGlastra TimoGlastra merged commit 34a6ff2 into openwallet-foundation:main Jul 19, 2021
@TimoGlastra TimoGlastra deleted the feat/add-inbound-transports branch July 19, 2021 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants