forked from retoor/devplacepy
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.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// 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}`);
|
||||
}
|
||||
Reference in New Issue
Block a user