feat: add collaborative Cloudflare cache and debug mode

This commit is contained in:
Darío Sevilla committed 2026-10-15 07:59:10 +00:00
1 parent 7e88fee0c2
commit 067cbfd24c
20 files changed
+695 -31

No files matched your search

+10
View File
@@ -3,6 +3,7 @@ const assert = require("node:assert/strict");
const { findUserRecord } = require("../lib/parser.js");
const { normalizeCountry, isBlacklisted } = require("../lib/config.js");
const { COUNTRIES, LOCATIONS } = require("../lib/countries.js");
const { normalizeEndpoint, hashHandle } = require("../lib/cloud-cache.js");
test("finds following state in nested X user data", () => {
const source = { data: { user: { result: { legacy: { screen_name: "Alice", following: true, location: "Berlin" } } } } };
@@ -23,3 +24,12 @@ test("offers the full country checklist with unique values", () => {
assert.ok(LOCATIONS.some((location) => location.name === "West Asia"));
assert.ok(LOCATIONS.some((location) => location.name === "United Kingdom" && location.flag === "🇬🇧"));
});
test("accepts only HTTPS cloud cache endpoints", () => {
assert.equal(normalizeEndpoint("https://cache.example.com/path"), "https://cache.example.com");
assert.equal(normalizeEndpoint("http://cache.example.com"), "");
assert.equal(normalizeEndpoint("not a URL"), "");
});
test("hashes handles case-insensitively before cloud lookup", async () => {
assert.equal(await hashHandle("Alice"), await hashHandle("alice"));
assert.match(await hashHandle("alice"), /^[a-f0-9]{64}$/);
});