Skip to content

add cron jobs#9

Merged
Remi561 merged 1 commit into
mainfrom
features/connected-to-frontend
Jun 25, 2026
Merged

add cron jobs#9
Remi561 merged 1 commit into
mainfrom
features/connected-to-frontend

Conversation

@Remi561

@Remi561 Remi561 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a daily maintenance task that automatically runs server-side upkeep on a schedule.
    • Introduced a protected maintenance endpoint to trigger background jobs on demand.
  • Bug Fixes

    • Improved handling of expired subscriptions and reminder processing by running related jobs together.
    • Added request validation for maintenance calls to prevent unauthorized execution.
  • Chores

    • Updated ignored files to exclude local editor settings.

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
subly Ready Ready Preview, Comment Jun 25, 2026 2:03pm

@Remi561 Remi561 merged commit 123113f into main Jun 25, 2026
2 checks passed
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 13cf4e5b-e616-40e6-9d1e-407262853cfa

📥 Commits

Reviewing files that changed from the base of the PR and between ad53804 and 67686bc.

📒 Files selected for processing (10)
  • .github/workflows/maintainance.yml
  • .gitignore
  • server/server.js
  • server/src/config/env.js
  • server/src/controllers/maintainance.controller.js
  • server/src/jobs/sendExpired.js
  • server/src/jobs/sendReminder.js
  • server/src/jobs/syncRate.js
  • server/src/middlewares/verifyCronSecret.middleware.js
  • server/src/routes/maintainance.route.js

📝 Walkthrough

Walkthrough

Adds a daily GitHub Actions maintenance request, a protected backend route that runs three jobs concurrently, and a cron secret check before the jobs execute.

Changes

Maintenance automation

Layer / File(s) Summary
Maintenance job exports and controller
server/src/jobs/sendExpired.js, server/src/jobs/sendReminder.js, server/src/jobs/syncRate.js, server/src/controllers/maintainance.controller.js
sendExpired, sendReminder, and syncRate are exported for external callers, and jobsMaintainance runs them together with Promise.allSettled and returns the settled results.
Cron secret gate and route wiring
server/src/config/env.js, server/src/middlewares/verifyCronSecret.middleware.js, server/src/routes/maintainance.route.js, server/server.js
CRON_SECRET is added to env, the x-cron-secret header is checked against it, and the maintenance router is mounted at /api/jobs.
Daily scheduler
.github/workflows/maintainance.yml
A daily GitHub Actions workflow sends a POST request to the maintenance endpoint with the x-cron-secret header from CRON_SECRET.

Sequence Diagram(s)

sequenceDiagram
  participant DailyMaintenanceWorkflow as Daily Maintenance workflow
  participant jobsMaintainanceRouter as jobsMaintainanceRouter
  participant verifyCronSecret as verifyCronSecret
  participant jobsMaintainance as jobsMaintainance
  participant syncRate as syncRate
  participant sendReminder as sendReminder
  participant sendExpired as sendExpired
  participant Prisma as Prisma
  DailyMaintenanceWorkflow->>jobsMaintainanceRouter: POST /api/jobs/maintainance
  jobsMaintainanceRouter->>verifyCronSecret: read x-cron-secret
  verifyCronSecret-->>jobsMaintainanceRouter: allow or 401
  jobsMaintainanceRouter->>jobsMaintainance: invoke controller
  jobsMaintainance->>syncRate: Promise.allSettled
  jobsMaintainance->>sendReminder: Promise.allSettled
  jobsMaintainance->>sendExpired: Promise.allSettled
  syncRate->>Prisma: upsert EUR rates
  sendReminder->>Prisma: create notifications
  sendExpired->>Prisma: update expired subscriptions
  jobsMaintainance-->>DailyMaintenanceWorkflow: JSON response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Remi561/Subly#8: Introduced exported cron job implementations and external wiring that this PR now exposes through the maintenance route and daily workflow.

Poem

A bunny tapped the midnight clock,
Then hopped to watch the jobs unlock.
With secret carrots tucked in place,
The maintenance burrow ran with grace. 🐇

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch features/connected-to-frontend

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot mentioned this pull request Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant