Skip to content

feat(docs): add /api/revalidate endpoint with default all-locale revalidation#15871

Draft
dsinghvi wants to merge 1 commit into
mainfrom
cursor/revalidate-all-locales-default-3319
Draft

feat(docs): add /api/revalidate endpoint with default all-locale revalidation#15871
dsinghvi wants to merge 1 commit into
mainfrom
cursor/revalidate-all-locales-default-3319

Conversation

@dsinghvi
Copy link
Copy Markdown
Member

Description

This PR adds a new /api/revalidate endpoint to the docs preview server that revalidates locale translations on demand.

Changes Made

  • Added /api/revalidate POST endpoint to both Express (Node.js) and Bun server implementations
  • Default behavior: Revalidates all configured locales when no locale parameter is provided
  • Specific locale: Revalidates only the specified locale when locale parameter is passed (e.g., {"locale": "fr"})
  • Returns a JSON response with the list of revalidated locale codes
  • Includes proper error handling for missing docs definitions and invalid locale codes

API Usage

Revalidate all locales (default):

curl -X POST http://localhost:PORT/api/revalidate -H "Content-Type: application/json" -d '{}'
# Response: {"revalidated": ["fr", "es", "de"]}

Revalidate specific locale:

curl -X POST http://localhost:PORT/api/revalidate -H "Content-Type: application/json" -d '{"locale": "fr"}'
# Response: {"revalidated": ["fr"]}

Testing

  • Code compiles successfully
  • Formatting and linting checks pass
  • Manual testing with docs preview server (requires running server with translated content)
  • Unit tests (follow-up if needed)

Slack Thread

Open in Web Open in Cursor 

…lidation

Add a new /api/revalidate endpoint to the docs preview server that:
- Revalidates all locales by default when no locale parameter is provided
- Revalidates only a specific locale when locale parameter is provided
- Returns list of revalidated locales in the response
- Supports both Node.js (Express) and Bun server implementations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants