How sctg-development/turgeand-messaging works
Project type and purpose
• This is a serverless, event-driven microservice built as a Cloudflare Worker.
• Its primary purpose is to receive SMS webhooks from Twilio, persist them in Cloudflare KV storage, and expose a secured API to retrieve stored messages.
File structure
• Top-level scripts and configs:
• package.json, tsconfig.json, vitest.config.mts, .github/workflows/vitest.yml (build, test, CI)
• gen_api_password.sh, setlicense.mjs, scripts to encrypt/decrypt sensitive data under _sensitive_datas
• src/index.ts – The Worker’s entry point, implementing HTTP handlers for /twilio/incoming and /twilio/read.
• test/… – Local unit and integration tests (Vitest, shell wrapper).
• worker-configuration.d.ts – Type bindings for KV namespaces and environment variables.
README for additional insights
• Endpoints:
• POST /twilio/incoming – parses Twilio’s form-encoded webhook, writes to KV with key INCOMING:{to}:{MessageSid}
• GET /twilio/read?to={number} – Basic Auth, reads all keys matching INCOMING:{to}:*, returns JSON array
• KV namespace: “TWILIO_KV” for both messages and user password hashes (USER:{username})
• Authentication: bcrypt-based password hashes stored in KV, validated in the Worker
• Development and deployment use Wrangler; CI runs Vitest on GitHub Actions