feat: add Obsidian CLI API service
Build and Push Docker Container / build-and-push (push) Successful in 4m26s
Build and Push Docker Container / build-and-push (push) Successful in 4m26s
- Add Docker image for the official Obsidian desktop app and CLI. - Start Obsidian headlessly with Xvfb and DBus setup. - Expose a safe structured HTTP command API without shell execution. - Add JWT-based vault, path, and command authorization. - Support single-vault and multi-vault container mounts. - Add TypeScript SDK helpers for Obsidian CLI commands. - Add n8n community node package with Obsidian operations. - Add docs, compose config, tests, and production image workflow.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
from pathlib import Path
|
||||
import json, os
|
||||
|
||||
JWT_SECRET = os.getenv("OBSIDIAN_JWT_SECRET", "")
|
||||
DEFAULT_TIMEOUT = float(os.getenv("COMMAND_TIMEOUT", "60"))
|
||||
MAX_TIMEOUT = float(os.getenv("MAX_COMMAND_TIMEOUT", "300"))
|
||||
CLI_BIN = os.getenv("OBSIDIAN_CLI_BIN", "obsidian")
|
||||
VAULT_PATH = Path(os.getenv("OBSIDIAN_VAULT_PATH", "/vault")).resolve()
|
||||
HOST = os.getenv("OBSIDIAN_API_HOST", "0.0.0.0")
|
||||
PORT = int(os.getenv("OBSIDIAN_API_PORT", "8080"))
|
||||
|
||||
def parse_registered_vaults() -> dict[str, str]:
|
||||
raw = os.getenv("OBSIDIAN_VAULTS", "").strip()
|
||||
vaults:dict[str, str] = {}
|
||||
|
||||
if raw:
|
||||
try:
|
||||
parsed = json.loads(raw)
|
||||
if isinstance(parsed, dict):
|
||||
return {str(name): str(path) for name, path in parsed.items()}
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
for chunk in raw.replace("\n", ",").split(","):
|
||||
chunk = chunk.strip()
|
||||
if not chunk or "=" not in chunk:
|
||||
continue
|
||||
name, path = chunk.split("=", 1)
|
||||
vaults[name.strip()] = path.strip()
|
||||
|
||||
if not vaults:
|
||||
vaults[VAULT_PATH.name or "vault"] = str(VAULT_PATH)
|
||||
|
||||
return vaults
|
||||
|
||||
REGISTERED_VAULTS = parse_registered_vaults()
|
||||
DEFAULT_VAULT_NAME = next(iter(REGISTERED_VAULTS), VAULT_PATH.name or "vault")
|
||||
Reference in New Issue
Block a user