Implement BWTYA API endpoints and background jobs#1
Open
railway-app[bot] wants to merge 1 commit intomainfrom
Open
Implement BWTYA API endpoints and background jobs#1railway-app[bot] wants to merge 1 commit intomainfrom
railway-app[bot] wants to merge 1 commit intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
src/lib/supabase.jssrc/lib/openai.jssrc/lib/defillama.jssrc/lib/superfluid.jssrc/lib/churches.jssrc/lib/auth.jssrc/lib/scripture.jssrc/routes/market.jssrc/routes/scripture.jssrc/routes/churches.jssrc/routes/mcp.jssrc/routes/streams.jssrc/routes/x402.jssrc/routes/a2a.jssrc/jobs/index.jssrc/db/schema.sqlsrc/middleware/index.jsindex.jspackage.json.env.exampleGenerated by Railway