Registry / devops / dwarf-client

dwarf-client

JSON →
library1.0.7jsnpmunverified

A gRPC client library for the Dwarf URL shortening microservice. Version 1.0.7 provides a simple async API to shorten multiple URLs via a gRPC endpoint configured through the DWARF_GRPC_SERVER environment variable. It is designed for Node.js web servers and uses @grpc/grpc-js for gRPC connectivity. The library is minimal and focuses on batch shortening with error propagation. Compared to HTTP-based URL shorteners, it offers lower latency through gRPC streaming. Release cadence is irregular; no recent updates since 1.0.7.

npm install dwarf-client
INSTALL
IMPORT
SIG · DWARF-CLIENT
D
dwarf-client
devopsjavascriptv1.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

shorten
import { shorten } from 'dwarf-client'
const shorten = require('dwarf-client').shorten
Package is ESM-only. Use import syntax in Node.js with ESM enabled.
DwarfClient
import { DwarfClient } from 'dwarf-client'
import DwarfClient from 'dwarf-client'
DwarfClient is a named export, not a default export.
ShortenResponse
import { ShortenResponse } from 'dwarf-client'
TypeScript users can import this type for response shapes.

Demonstrates importing the shorten function and batch-shortening two URLs, logging the result.

import { shorten } from 'dwarf-client'; async function main() { try { const result = await shorten(['http://example.com', 'https://test.org']); console.log('Shortened URLs:', result.urls); } catch (err) { console.error('Error:', err); } } main();
Debug
Known issues
gotchaThe gRPC server address must be set via the DWARF_GRPC_SERVER environment variable, otherwise the client will fail to connect.
fix
Set DWARF_GRPC_SERVER environment variable, e.g., export DWARF_GRPC_SERVER=localhost:50051
affects: >=0.0.0
gotchaThe package is ESM-only; CommonJS require() will not work without transpilation.
fix
Use import syntax or enable ESM in your project (type: module in package.json).
affects: >=1.0.0
deprecatedAll functions are synchronous wrappers; errors are thrown synchronously, not passed to callbacks.
fix
Wrap calls in try/catch blocks as shown in the documentation.
affects: >=0.0.0
Errors
Common errors & fixes
Error: 14 UNAVAILABLE: DNS resolution failed
The DWARF_GRPC_SERVER environment variable is not set or points to an unreachable server.
fix
Ensure DWARF_GRPC_SERVER is defined and the gRPC server is running.
Cannot find module 'dwarf-client' or its corresponding type declarations
Project is using CommonJS require() or TypeScript with esModuleInterop disabled.
fix
Use import { shorten } from 'dwarf-client' and enable esModuleInterop in tsconfig.json.
TypeError: shorten is not a function
Default import was used instead of named import.
fix
Change import DwarfClient from 'dwarf-client' to import { shorten } from 'dwarf-client'.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredRequired for gRPC client connectivity.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
dwarf-client — npm install dwarf-client · libregistry