Repository navigation
feat(reliability,security): production cron sync, auth hardening, app consolidation & CI - #8
Merged
Merged
Conversation
… GitHub Actions CI workflow
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…esolution for test runner
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR addresses critical reliability, security, architecture, and UI findings identified in the Phase 1 audit. It introduces production-ready scheduled background sync, hardens JWT authentication and session handling, eliminates duplicated server initialization, adds automated test suites with GitHub Actions CI, and polishes user-facing UI copy.
Key Changes
1. 🔄 Scheduled Background Sync in Production
/api/cron/sync(api/cron/sync.js) secured viaAuthorization: Bearer <CRON_SECRET>.syncAllUsers()inserver/services/sync.service.jswith deduplication (skips users synced within the last 2h) and throttled batch processing to prevent serverless execution timeouts.withTimeouthelper (12s ceiling per platform) so hanging external APIs (GitHub, LeetCode, Codeforces, WakaTime, Stack Overflow, npm/PyPI) do not stall the process..github/workflows/sync-cron.ymlrunning every 3 hours (0 */3 * * *) with manual trigger (workflow_dispatch) and concurrency protection.2. 🔐 Authentication & Session Hardening
algorithm: 'HS256'inauth.controller.js,auth.middleware.js, andauth.routes.js.console.loglogging raw password reset tokens inforgotPassword.'devact_session_secret'fallback;SESSION_SECRETis now required and validated.3. 🏗️ Consolidate Backend Entry Points
server/app.jswith shared middleware (Helmet, CORS, sessions, Passport, rate limiting, error handlers) and fail-fast environment validation.api/index.jsso per-requestconnectDB()middleware executes before route handlers.maxPoolSize: 10inserver/config/db.jsand ensured dynamicglobal.mongoosecaching across warm serverless invocations.4. 🧪 Automated Testing & CI Pipeline
vitestandsupertestto rootpackage.jsonwithnpm test.tests/auth.test.js: HS256 enforcement, expired/invalid token handling, protected route authorization.tests/cron-sync.test.js: Secret validation, 401/405/500 guards, bounded sync dispatching.tests/db.test.js: Serverless connection caching, pooling parameters, connection failure recovery..github/workflows/ci.ymlto run tests and verify the frontend build on pushes and PRs.User,SyncData) againstOverwriteModelError.5. 🎨 UI & Copy Polish
—) in user-facing copy acrossDashboard.jsx,CPTracker.jsx,PracticeReview.jsx,ManageAccount.jsx,Profile.jsx,Journal.jsx,Contests.jsx, andHome.jsx.Verification
npm testpasses 17 / 17 tests locally.npm --prefix client run buildsucceeds cleanly.Required Environment Variables / Secrets
CRON_SECRET,SESSION_SECRETCRON_SECRET,CRON_SYNC_URL