feat(marketplace): add indexer-backed caching and pagination (#504) - #552
Merged
barry01-hash merged 1 commit intoAug 31, 2026
Conversation
…intLabs#504) Replace the all-rows GetPrompts listing with a cached, paginated, searchable read model served from the event-indexed Prompt collection. - Add text + compound sort indexes to Prompt for scale - Add marketplaceIndexService: search/filter/sort with offset and keyset-cursor pagination, cache-aside in Redis under prompts:list:* - GetPrompts returns a paginated envelope (items/total/page/nextCursor/...) - Add GET /api/prompts/index/status for indexer visibility - Cover service and controller with tests
|
@NnamdiCyber Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Closes #504 — adds caching and pagination for the high-volume marketplace, served from the event indexer's Prompt collection (roadmap item: external indexer for search/pagination at scale).
The previous
GET /api/promptsreturned every published prompt with no pagination, search, or sort — untenable at scale. It now reads from the indexed collection through a cached, paginated, searchable read model.Changes
models/Prompt.js: added a full-text search index (title/content/category/tags) and compound sort indexes (createdAt, price, salesCount, rating, each paired with_id) so search/pagination avoid full collection scans.services/marketplaceIndexService.ts(new): the indexer-backed read model.searchMarketplace()supports:search,category,tags,minPrice/maxPrice,similarityFlag,walletAddressprompts:list:*— automatically invalidated byinvalidatePromptMetadataon every indexed contract eventcontrollers/controllers.ts:GetPromptsdelegates tosearchMarketplace, returning a paginated envelope (items/total/page/limit/totalPages/nextCursor/hasNext/cached) instead of a bare array. AddedGetMarketplaceIndexStatus.routes/promptRoutes.ts: newGET /api/prompts/index/statusfor indexer visibility (registered before/:id).marketplaceIndexService.test.ts+getPrompts.test.ts— 10/10 passing.Test plan
cd server && npx jest src/tests/marketplaceIndexService.test.ts src/tests/getPrompts.test.ts
Usage
GET /api/prompts?search=...&category=Programming&tags=ai,seo&minPrice=1&maxPrice=50&sort=price_desc&limit=24&cursor=
Notes
server/package-lock.jsonchange from localnpm installwas intentionally excluded from the commit.tscreports pre-existing type errors across many controllers (theasyncRoute/AsyncHandlermismatch from@types/express@5); none are introduced by this change, and the new code is type-clean.