feat: Add ElevenLabs API key support to Settings model (#422) #431
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.
Feat: Add ElevenLabs API Key Support to Settings Model
Closes #422
This PR implements support for users to securely store and manage their ElevenLabs API Key within their Cboard settings model. This lays the groundwork for future server-side integrations with ElevenLabs text-to-speech services.
Implementation Details 🛠️
This feature required synchronized changes across the Model (Schema) and the Controller (API Logic) to ensure both persistence and security.
1. Database Model (
../models/Settings.js)elevenlabsApiKeyfield to theSettingsSchema.select: falseto ensure the sensitive key is never loaded by default, adhering to security best practices.Settings.getOrCreateto accept an optionalincludeSecretsflag to conditionally force selection of the key when needed by the controller (i.e., for updates or sanitization).2. Settings Controller (
settings.js)updateSettings): Added logic to check for theelevenlabsApiKeyin the request body, saving it to the database after trimming whitespace. It saves an empty string asnullfor consistency.getSafeSettingsResponse, which is used in bothgetSettingsandupdateSettings. This function:elevenlabsKeySet(boolean) andelevenlabsKeyPreview(last 4 characters).Verification (Tested Behavior)
" ") ornullsuccessfully clears the key from the database.GET /settingsAPI response no longer contains theelevenlabsApiKeyfield, but correctly returns the status flags:elevenlabsKeySet: true/false.