mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
12 lines
518 B
TypeScript
12 lines
518 B
TypeScript
import { join } from "node:path";
|
|
import { validateUnixSocketPath } from "./listener.ts";
|
|
|
|
/** Derive the local Unix socket path for one logical service identity. */
|
|
export function getUnixSocketPath(serviceId: string, serverDirectory: string): string {
|
|
if (!/^[0-9a-f]{32}$/.test(serviceId)) {
|
|
throw new TypeError("Unix serviceId must be 32 lowercase hexadecimal characters");
|
|
}
|
|
const path = join(serverDirectory, `${serviceId}.sock`);
|
|
validateUnixSocketPath(path, "PiServer Unix socket path");
|
|
return path;
|
|
}
|