Files
devplacepy/examples/devrant/post_rant.mjs
T
retoor c151325916 feat: add plug-and-play devRant API client examples with Python and JavaScript
Add complete set of example scripts for the devRant REST protocol under
examples/devrant/, including reusable client libraries, a rant poster,
a live feed watcher with keyword-based auto-upvote, and an end-to-end
smoke test that exercises every endpoint. Both Python (stdlib-only) and
JavaScript (Node 18+ global fetch) implementations are provided.
2026-06-14 07:48:37 +00:00

21 lines
485 B
JavaScript

// retoor <retoor@molodetz.nl>
import { fromEnv } from "./client.mjs";
const text = process.argv[2];
const tags = process.argv[3] || "";
if (!text) {
console.log("usage: DEVRANT_USERNAME=.. DEVRANT_PASSWORD=.. node post_rant.mjs <text> [tags]");
process.exit(1);
}
const api = fromEnv();
await api.login();
const result = await api.postRant(text, tags);
if (result.success) {
console.log(`posted rant ${result.rant_id}`);
} else {
console.log(`failed: ${result.error}`);
}