Remove custom API endpoints in favor of Payload's native REST API

- Removed custom endpoint handler and endpoints directory
- Removed enableApi configuration option from plugin
- Updated client hooks to use Payload's native collection API
- Updated documentation to reflect API changes
- Updated view component to handle Payload API response format

The plugin now uses Payload CMS's built-in REST API for the feature-flags collection, which provides standard query syntax, pagination, and automatic access control enforcement.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-03 14:17:11 +02:00
parent 93673d1b14
commit a6712666af
11 changed files with 260 additions and 209 deletions

View File

@@ -56,10 +56,10 @@ The plugin follows Payload's plugin architecture with multiple exports:
- `getUserVariant()`: A/B testing variant selection
- `getFeatureFlagsByTag()`: Query flags by tags
#### API Endpoints (`src/endpoints/customEndpointHandler.ts`)
- `GET /api/feature-flags` - List all active feature flags
- `GET /api/feature-flags/:flag` - Get specific flag data
- Only created when `enableApi: true`
#### API Access
- The plugin uses Payload's native REST API for the feature-flags collection
- Standard Payload query syntax is supported
- Collection access controls are enforced
### Collection Schema
The plugin creates a feature flags collection with these key fields:
@@ -93,9 +93,9 @@ The plugin integrates with Payload by:
4. Supporting full collection customization through `collectionOverrides`
### Security Considerations
- REST API endpoints are disabled by default (`enableApi: false`)
- Server-side hooks are the preferred method for accessing feature flags
- Collection access can be restricted through `collectionOverrides.access`
- API access follows standard Payload authentication and authorization
### Testing Setup
The development configuration (`dev/payload.config.ts`) includes: