mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
This commit addresses CodeRabbit feedback from PR #186 by adding detailed documentation to all public APIs in the settings module: **Server-side documentation:** - SettingsService class: 12 public methods with parameter and return types - Settings types (settings.ts): All type aliases, interfaces, and constants documented with usage context - Route handlers (8 endpoints): Complete endpoint documentation with request/response schemas - Automaker paths utilities: All 13 path resolution functions fully documented **Client-side documentation:** - useSettingsMigration hook: Migration flow and state documented - Sync functions: Three sync helpers (settings, credentials, project) with usage guidelines - localStorage constants: Clear documentation of migration keys and cleanup strategy All docstrings follow JSDoc format with: - Purpose and behavior description - Parameter documentation with types - Return value documentation - Usage examples where applicable - Cross-references between related functions This improves code maintainability, IDE autocomplete, and developer onboarding. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/**
|
|
* GET /api/settings/credentials - Get API key status (masked for security)
|
|
*
|
|
* Returns masked credentials showing which providers have keys configured.
|
|
* Each provider shows: `{ configured: boolean, masked: string }`
|
|
* Masked shows first 4 and last 4 characters for verification.
|
|
*
|
|
* Response: `{ "success": true, "credentials": { anthropic, google, openai } }`
|
|
*/
|
|
|
|
import type { Request, Response } from "express";
|
|
import type { SettingsService } from "../../../services/settings-service.js";
|
|
import { getErrorMessage, logError } from "../common.js";
|
|
|
|
/**
|
|
* Create handler factory for GET /api/settings/credentials
|
|
*
|
|
* @param settingsService - Instance of SettingsService for file I/O
|
|
* @returns Express request handler
|
|
*/
|
|
export function createGetCredentialsHandler(settingsService: SettingsService) {
|
|
return async (_req: Request, res: Response): Promise<void> => {
|
|
try {
|
|
const credentials = await settingsService.getMaskedCredentials();
|
|
|
|
res.json({
|
|
success: true,
|
|
credentials,
|
|
});
|
|
} catch (error) {
|
|
logError(error, "Get credentials failed");
|
|
res.status(500).json({ success: false, error: getErrorMessage(error) });
|
|
}
|
|
};
|
|
}
|