Fix code synchronization issues: unify language constants, enhance health check service, and resolve type inconsistencies #6
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.
This PR addresses critical synchronization issues discovered during a comprehensive codebase analysis. The main problems were inconsistent language constant definitions across multiple files, incorrect health check uptime calculations, and TypeScript compilation errors due to type mismatches.
Key Issues Fixed
Language Constants Synchronization
The codebase had three different language constant definitions that were out of sync:
LANGUAGESin/src/types/index.ts(19 languages)SUPPORTED_LANGUAGESin/src/services/language-manager.ts(19 different languages)LANGUAGESin/src/bot/leitner-bot.ts(20+ languages)This inconsistency caused issues where:
Solution: Unified all language definitions into a single source of truth in
/src/types/index.tswith 25 supported languages, and updated all imports to use this centralized constant.Health Check Service Issues
The health check service was calculating "uptime" incorrectly as the execution time of the health check function rather than the actual service uptime:
Solution: Implemented proper service uptime tracking using a global
serviceStartTimevariable and enhanced the service with persistent system stats storage in KV store.Environment Compatibility
The admin API was using Node.js-specific
process.versionandprocess.platformproperties that are not available in Cloudflare Workers:TypeScript Type Safety
Fixed multiple TypeScript compilation errors related to strict typing of language button arrays and callback structures. Added proper type annotations to ensure type safety while maintaining flexibility.
Impact
Testing
The codebase is now fully synchronized with consistent language support, proper monitoring capabilities, and zero compilation errors.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.