@liteguard/liteguard-node
v0.6.20260405
Published
Liteguard SDK for Node.js runtimes. Feature guards, observability, and security response evaluated locally with zero network overhead per check
Downloads
498
Maintainers
Readme
@liteguard/liteguard-node
- Website: liteguard.io
- Project Page: https://github.com/liteguard/liteguard
- Issues: https://github.com/liteguard/liteguard/issues/new
Liteguard for Node.js.
Installation
npm install @liteguard/liteguard-nodeQuick Start
import { LiteguardClient } from "@liteguard/liteguard-node";
const client = new LiteguardClient("pct-...", {
environment: "env-production",
});
await client.start();
const scope = client.createScope({ userId: "user-123", plan: "pro" });
if (scope.isOpen("payments.checkout")) {
// ...
}
await client.shutdown();Primary API
new LiteguardClient(projectClientToken, options)creates a client.await client.start()fetches the initial bundle and starts refresh and flush workers.client.createScope()creates an immutable scope.scope.isOpen()evaluates locally.scope.evaluate()returns aGuardDecisionwith the full evaluation result.scope.executeIfOpen()andscope.executeIfOpenAsync()measure guarded work.scope.startExecution()creates an execution correlation handle.scope.withProperties()andscope.withProtectedContext()derive child scopes.scope.getProperties()returns the current property bag for transport.client.flush()flushes buffered telemetry.client.shutdown()flushes and stops background work.
Convenience helpers
For server applications that want request-scoped context propagation:
client.runWithScope(scope, fn)runsfnwithscopeas the active scope, propagated acrossawaitboundaries viaAsyncLocalStorage.client.getActiveScope()returns the scope bound to the current request.client.withProperties(properties, fn)derives and activates a scope with additional properties.client.withProtectedContext(protectedContext, fn)derives and activates a protected scope.
Notes
- Evaluation is local after the initial bundle fetch.
- Prefer explicit client and scope usage.
- Unadopted guards default open and emit no signals.
- The convenience helpers above also serve as infrastructure for auto-instrumentation of third-party dependencies. See the Liteguard CLI for build-time instrumentation.
License
Apache 2.0 see LICENSE.
