Skip to content

feat(nodejs): implement Node.js binding core code#424

Open
Spockkk0225 wants to merge 50 commits into
mainfrom
feat/nodejs_bind
Open

feat(nodejs): implement Node.js binding core code#424
Spockkk0225 wants to merge 50 commits into
mainfrom
feat/nodejs_bind

Conversation

@Spockkk0225
Copy link
Copy Markdown
Collaborator

Related Issues

Fixes #423

What does this PR do?

Add Node.js bindings for NeuG, providing a native C++ addon (N-API / node-addon-api) and a high-level JavaScript API layer for embedded graph database access with Cypher query support.

What changes in this PR?

  • C++ native addon (tools/nodejs_bind/src/): NodeDatabase, NodeConnection, NodeQueryResult, NodeQueryRequest classes exposed via Napi::ObjectWrap
  • JavaScript API layer (tools/nodejs_bind/lib/): Database, Connection, AsyncConnection, Session, QueryResult and formatting utilities
  • Build integration: CMake support via -DBUILD_NODEJS=ON, produces neug_node_bind.node addon
  • Package config: package.json with N-API v8, Node >= 18, node-addon-api ^8.0.0
  • Fix lib/ being ignored by root .gitignore

@Spockkk0225 Spockkk0225 requested a review from BingqingLyu May 28, 2026 06:40
@Spockkk0225 Spockkk0225 changed the title feat(nodejs_bind): implement Node.js binding core code feat(nodejs): implement Node.js binding core code May 28, 2026
Copy link
Copy Markdown
Collaborator

@longbinlai longbinlai left a comment

Choose a reason for hiding this comment

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

Should release node.js package to npm.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 1, 2026

CLA assistant check
All committers have signed the CLA.

@Spockkk0225 Spockkk0225 requested review from BingqingLyu and removed request for BingqingLyu June 2, 2026 02:39
@zhanglei1949
Copy link
Copy Markdown
Member


build_npm_linux_x86_64:
needs: format_check
runs-on: [self-hosted, daily, linux, x64]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please refer to https://github.com/alibaba/neug/blob/main/.github/workflows/neug-test.yml#L61 for invoking to different runners for different repo(forked repo or alibaba/neug)

make build EXTRA_CMAKE_FLAGS="-DOPTIMIZE_FOR_HOST=OFF -DCMAKE_PREFIX_PATH=/opt/neug/ -DOPENSSL_ROOT_DIR=/opt/neug"
'

- name: Pack
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Separate pack from building. For pull request even, running test on linux x86 is enough.
For packing on different platforms, run it as a nightly job.

path: ./tools/nodejs_bind/neug-*-linux_x86_64.tgz
if-no-files-found: error

build_npm_linux_arm64:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The most part of build_npm_linux/macos_x86/arm64 are same. Please refer to https://github.com/alibaba/neug/blob/main/.github/workflows/wheels-common.yml merge them as a single job with params.

@@ -0,0 +1,142 @@
<a id="neug.connection"></a>

# Module neug.connection
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Spockkk0225 @longbinlai We may need to review the generated documentation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please follow https://github.com/alibaba/neug/blob/main/doc/README.md to build doc at local

@@ -0,0 +1,208 @@
/** Copyright 2020 Alibaba Group Holding Limited.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we generate this with protoc?


namespace neug {

void SetupLogging() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Duplicated to python_bind/neug_bindings.cc


} // namespace neug

static Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is Napi the best practice for nodejs bindings?

@@ -0,0 +1,2435 @@
/** Copyright 2020 Alibaba Group Holding Limited.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Duplicated to test_db_query.py, we don't NEED so many code

@@ -0,0 +1,11 @@
node_modules/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please merge .gitignore to repo root .gitignore

Comment thread .gitignore

# outer build directory
build/
build_nodejs/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we don't need this line

Comment thread tools/CMakeLists.txt
endif()

if (BUILD_NODEJS)
if (TARGET neug_main)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

neug_main must be built. Remove the dummy check

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.

Implement Node.js binding core code & test & ci

4 participants