All files / kernel-utils/src/nodejs libp2p-relay-home.ts

100% Statements 1/1
100% Branches 2/2
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                                2x    
import { homedir } from 'node:os';
import { join } from 'node:path';
 
/**
 * Get the libp2p relay's bookkeeping directory. This is where the relay
 * writes its PID file and multiaddr file, and where the daemon's
 * `--local-relay` mode reads them. It is intentionally separate from
 * `OCAP_HOME`: a single libp2p relay serves any number of OCAP daemons
 * on the same host, regardless of which `OCAP_HOME` each daemon uses.
 *
 * Defaults to `~/.libp2p-relay`; overridable with `LIBP2P_RELAY_HOME`.
 *
 * @returns The absolute path to the libp2p relay state directory.
 */
export function getLibp2pRelayHome(): string {
  // eslint-disable-next-line n/no-process-env
  return process.env.LIBP2P_RELAY_HOME ?? join(homedir(), '.libp2p-relay');
}