Add API mod page search endpoint with scope checks#114
Add API mod page search endpoint with scope checks#114Alechilles wants to merge 4 commits intoHytaleModding:mainfrom
Conversation
|
Context: https://discord.com/channels/1440173445039132724/1477353404564246682/1490101028115316908 The purpose of this PR is to enable a Discord bot I made to search full content on the wiki instead of just slugs. I theoretically could scrape the pages and cache the content but it seems silly to essentially duplicate the content when we could just use the HytaleModding API directly. |
There was a problem hiding this comment.
Pull request overview
Adds a new API-key + scope protected endpoint to search published documentation pages for a given mod, along with supporting CLI scope discovery and feature tests.
Changes:
- Added
GET /api/mods/{mod}/pages/searchendpoint gated byread:mods:search. - Implemented page search in
ModController@search(title/slug/content matching + ranked ordering + snippets). - Added feature tests covering auth/scope/access checks, ranking behavior, and route collision regression.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Feature/Api/ModApiSearchTest.php | Adds feature tests for the new scoped search endpoint and route-collision regression. |
| routes/api.php | Registers the new /pages/search route with the read:mods:search scope middleware. |
| app/Http/Controllers/Api/Client/ModController.php | Implements the search handler, including validation, access checks, ranking, and response shaping. |
| app/Console/Commands/MakeApiKey.php | Exposes the new read:mods:search scope in the interactive scope selection list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Adds an API-key scoped search endpoint for mod documentation pages and hardens the implementation for production use.
What Changed
GET /api/mods/{mod}/pages/search(scope:read:mods:search)id,title,slug,kind,url, andsnippetread:mods:searchtomake:apikeyavailable scopesSecurity / Robustness
searchby using/pages/search%/_) with422to avoid broad table scansexternal_accesschecksPerformance / Consistency
ownereager load in the search mod lookup pathModControllerclient endpointsTests
read:mods:search)external_accessdenialsearchstill resolves viaGET /api/mods/{mod}/{page}156 tests, 599 assertions