Skip to content

Implement BWTYA API endpoints and background jobs#1

Open
railway-app[bot] wants to merge 1 commit intomainfrom
railway/code-change-TESn9A
Open

Implement BWTYA API endpoints and background jobs#1
railway-app[bot] wants to merge 1 commit intomainfrom
railway/code-change-TESn9A

Conversation

@railway-app
Copy link
Copy Markdown

@railway-app railway-app bot commented Mar 28, 2026

Summary

Replaces all stubbed mock responses with fully functional implementations across every endpoint. The API is restructured into a clean src/ module tree: lib/ for shared utilities, routes/ for Express handlers, middleware/ for cross-cutting concerns, jobs/ for cron tasks, and db/ for the Supabase schema.

POST /v1/market fetches live Base chain TVL from DefiLlama and the Fear & Greed Index from alternative.me, with a 5-second Supabase cache and stale fallback. POST /v1/scripture-match generates OpenAI embeddings and runs pgvector cosine similarity against biblical_knowledge_base. GET|POST|PUT|DELETE /v1/churches is a full CRUD API with Google Maps address verification, JWT auth on write operations, and soft deletes. GET|POST|DELETE /v1/streams creates and stops real Superfluid CFA streams on Base via Viem. POST /x402 implements the HTTP 402 payment protocol — returns payment requirements when no header is present, verifies EIP-191 signatures when one is. POST /mcp speaks JSON-RPC 2.0 Model Context Protocol with tools/list and tools/call. POST /a2a implements Agent-to-Agent with ERC-8004 signature verification and action routing.

Four background jobs run via node-cron and setInterval: market cache refresh every 5 seconds, scripture embedding seeding hourly, church address re-verification hourly (offset 30 min), and validator reward calculation every 15 minutes via Superfluid GDA pool units. Middleware adds per-IP rate limiting (100 req/min global, 20 req/min on expensive endpoints), structured CORS for the Railway frontend, request logging, and a global error handler. src/db/schema.sql contains the complete Supabase DDL including the match_scriptures pgvector RPC function, and .env.example documents all required environment variables.

Changes

  • Created src/lib/supabase.js
  • Created src/lib/openai.js
  • Created src/lib/defillama.js
  • Created src/lib/superfluid.js
  • Created src/lib/churches.js
  • Created src/lib/auth.js
  • Created src/lib/scripture.js
  • Created src/routes/market.js
  • Created src/routes/scripture.js
  • Created src/routes/churches.js
  • Created src/routes/mcp.js
  • Created src/routes/streams.js
  • Created src/routes/x402.js
  • Created src/routes/a2a.js
  • Created src/jobs/index.js
  • Created src/db/schema.sql
  • Created src/middleware/index.js
  • Modified index.js
  • Modified package.json
  • Created .env.example

Generated by Railway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants