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

Node.js bindings #234

Closed
janvanbouwel opened this issue Jul 24, 2023 · 3 comments
Closed

Node.js bindings #234

janvanbouwel opened this issue Jul 24, 2023 · 3 comments

Comments

@janvanbouwel
Copy link
Contributor

Last month I've worked on new bindings for node.js in typescript using node-gypand node-addon-api. Blocking calls are made asynchronous, using the latter API to interact with libuv. TCP matches closely to nodes net module and should be interoperable with e.g. the http module. Same for UDP (node:dgram), though UDP does not support connections yet (instead specify destination every time).

It's not finished, but I've had less time to work on it so thought I'd share it already, to also get some feedback. Biggest issue currently is figuring out how to best build/package it, something I don't have much experience with. (It's also currently Linux only as I don't have Windows or Mac to test on, it's hopefully just configuring the paths.)

Code is here: https://github.com/janvanbouwel/libzt/tree/node/src/bindings/nodejs (I'll create a PR as well)

https://github.com/janvanbouwel/libzt/tree/node-test-release is an attempt at packaging it. It includes a prebuilt libzt.a. It can be installed using npm, which builds the bindings and links it automatically. The only issue is npm not liking a package being placed in a subfolder of a git repository, instead https://gitpkg.now.sh/janvanbouwel/libzt/src/bindings/nodejs?node-test-release can be used. I've made an example project at https://github.com/janvanbouwel/libzt-node-example that demonstrates this.

@joseph-henry
Copy link
Contributor

Dude, this is awesome. I'll try to take a look soon and not keep you and your PR hanging. This is something we've wanted to properly support for a long time.

@janvanbouwel
Copy link
Contributor Author

Nice to hear. I'm sure many improvements are possible, but it works and I've tried to make a solid base to work off of. That being said, documentation is a bit sparse, so let me know if anything needs clarification.

@joseph-henry
Copy link
Contributor

Closing this to consolidate discussion into your PR #235

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

No branches or pull requests

2 participants