mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-13 21:47:46 +00:00
nodejs: download prebuilt add-on at runtime
This commit is contained in:
@@ -55,9 +55,11 @@ If you cloned this repository, you can:
|
||||
cd ./packages/simplex-chat-nodejs
|
||||
npm install
|
||||
npm run build
|
||||
node ./examples/squaring-bot-readme.js
|
||||
SIMPLEX_ADDON_PATH=build/Release/simplex.node node ./examples/squaring-bot-readme.js
|
||||
```
|
||||
|
||||
Building the Node.js add-on from source needs [node-gyp](https://github.com/nodejs/node-gyp) build tools.
|
||||
|
||||
There is an example with more options in [./examples/squaring-bot.ts](./examples/squaring-bot.ts).
|
||||
|
||||
You can run it with: `npx ts-node ./examples/squaring-bot.ts`
|
||||
@@ -66,14 +68,14 @@ A larger example, with a business address and commands as keys: [SimpleX Calcula
|
||||
|
||||
## Native library
|
||||
|
||||
`libsimplex` is downloaded on first use into the user cache (`$XDG_CACHE_HOME/simplex-chat` or `~/.cache/simplex-chat` on Linux, `~/Library/Caches/simplex-chat` on macOS, `%LOCALAPPDATA%\simplex-chat` on Windows), shared with the Python library. To download it ahead of time, for example in a Dockerfile, run as the user that runs the app:
|
||||
`libsimplex` and the prebuilt Node.js add-on are downloaded on first use into the user cache (`$XDG_CACHE_HOME/simplex-chat` or `~/.cache/simplex-chat` on Linux, `~/Library/Caches/simplex-chat` on macOS, `%LOCALAPPDATA%\simplex-chat` on Windows), shared with the Python library. To download them ahead of time, for example in a Dockerfile, run as the user that runs the app:
|
||||
|
||||
```bash
|
||||
npx simplex-chat install # sqlite (default)
|
||||
npx simplex-chat install --backend postgres # Linux x86_64 only
|
||||
```
|
||||
|
||||
Set `SIMPLEX_LIBS_DIR` to a directory with a local build of `libsimplex` and its dependencies to use it instead; it must be built for the backend in use.
|
||||
Set `SIMPLEX_LIBS_DIR` to a directory with a local build of `libsimplex` and its dependencies to use it instead; it must be built for the backend in use. Set `SIMPLEX_ADDON_PATH` to a locally built add-on (`build/Release/simplex.node`) to use it instead of the downloaded one.
|
||||
|
||||
`ChatApi.init` loads the library for `DbConfig.type`; the low-level `core` functions require `core.loadLibrary(backend)` first.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user