@nexus-js/node-ipc
v0.3.1
Published
Node IPC adapter for Nexus framework
Readme
@nexus-js/node-ipc
@nexus-js/node-ipc is the Nexus adapter for local daemon/client IPC over filesystem Unix domain sockets.
For the product guide, read docs/node-ipc/README.md from the repository root. This package README is a short reference for installation, exports, and the minimum setup shape.
Install
pnpm add @nexus-js/core @nexus-js/node-ipcExports
Factory helpers:
usingNodeIpcDaemon(options)usingNodeIpcClient(options)
Matcher helpers:
daemon(appId)client(appId)instance(name)group(name)
Public types and errors:
NodeIpcErrorNodeIpcErrorCodeNodeIpcAddressNodeIpcAddressResolverNodeIpcSocketAddressNodeIpcEndpointMetaNodeIpcDaemonMetaNodeIpcClientMetaNodeIpcPlatformMeta- factory option types
Minimal Daemon
import { nexus } from "@nexus-js/core";
import { usingNodeIpcDaemon } from "@nexus-js/node-ipc";
import { EchoToken } from "./shared";
usingNodeIpcDaemon({ appId: "example-app" }).provide(EchoToken, {
async echo(input) {
return `echo:${input}`;
},
});Minimal Client
import { nexus } from "@nexus-js/core";
import { usingNodeIpcClient } from "@nexus-js/node-ipc";
import { EchoToken } from "./shared";
usingNodeIpcClient({
appId: "example-app",
connectTo: [
{
descriptor: { context: "node-ipc-daemon", appId: "example-app" },
},
],
});
const echo = await nexus.create(EchoToken);
console.log(await echo.echo("hello"));Runtime Notes
- Default socket path:
$XDG_RUNTIME_DIR/nexus/<appId>/<instance>.sock - Fallback socket path:
/tmp/nexus-<uid>/<appId>/<instance>.sock instancedefaults todefault- Shared-secret pre-auth is optional and configured with
authToken - Core
policy.canConnectandpolicy.canCallremain the authorization authority after pre-auth create(EchoToken)requires a tokendefaultTargetor a uniqueconnectTofallback; use explicittargetplusexpectsfor complex daemon topologies- Proxies and refs are session-bound; recreate them after daemon restart or disconnect
Error Codes
E_IPC_ADDRESS_INVALIDE_IPC_ADDRESS_IN_USEE_IPC_PATH_TOO_LONGE_IPC_CONNECT_FAILEDE_IPC_AUTH_FAILEDE_IPC_PROTOCOL_ERRORE_IPC_STALE_SOCKET_CLEANUP_FAILED
Tests
pnpm --filter @nexus-js/node-ipc test