Skip to content

Conversation

@aXenDeveloper
Copy link
Owner

Improving Documentation

Description

What?

Why?

How?

@vercel
Copy link

vercel bot commented Aug 30, 2025

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

Project Deployment Preview Comments Updated (UTC)
vitnode-docs Ready Ready Preview Comment Sep 6, 2025 10:41am

@aXenDeveloper
Copy link
Owner Author

@codex

@aXenDeveloper aXenDeveloper requested a review from Copilot August 30, 2025 13:27
@chatgpt-codex-connector
Copy link

Summary

Testing

  • pnpm lint
  • pnpm test

View task →

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements CRON jobs API functionality for VitNode, introducing a comprehensive system for scheduling and managing background tasks. The implementation includes database schema, API routes, adapters, and configuration updates.

Key changes:

  • Adds CRON jobs infrastructure with database table, API module, and scheduling framework
  • Refactors plugin configuration to use explicit pluginId instead of spread syntax
  • Updates package dependencies and removes Prettier configuration references

Reviewed Changes

Copilot reviewed 76 out of 77 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/vitnode/src/database/cron.ts Creates core_cron database table schema
packages/vitnode/src/api/lib/cron.ts Defines CRON adapter interface and buildCron function
packages/vitnode/src/api/modules/cron/ Implements CRON API module with routes and test job
packages/vitnode/src/api/lib/module.ts Adds cronJobs support to module builder
packages/vitnode/src/api/lib/plugin.ts Integrates CRON jobs into plugin system
packages/vitnode/src/vitnode.config.ts Adds cronAdapter configuration option
Multiple plugin files Refactors from spread CONFIG_PLUGIN to explicit pluginId
Migration files Database migration for core_cron table
Documentation files Updates SSO, email, and other docs with formatting fixes
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment on lines 27 to 28
// biome-ignore lint/suspicious/noConsole: needed for testing cron functionality
console.log("Cron job triggered", c.get("core").cron);
Copy link

Copilot AI Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console.log statement should use the logger from context instead of direct console access. Replace with c.get('log').info('Cron job triggered', c.get('core').cron).

Suggested change
// biome-ignore lint/suspicious/noConsole: needed for testing cron functionality
console.log("Cron job triggered", c.get("core").cron);
c.get('log').info('Cron job triggered', c.get('core').cron);

Copilot uses AI. Check for mistakes.
Comment on lines 7 to 9
handler: () => {
// biome-ignore lint/suspicious/noConsole: needed for testing cron functionality
console.log("Test cron job executed");
Copy link

Copilot AI Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console.log statement should use the logger from context instead of direct console access. Consider using the context parameter in the handler function to access the logger.

Suggested change
handler: () => {
// biome-ignore lint/suspicious/noConsole: needed for testing cron functionality
console.log("Test cron job executed");
handler: (context) => {
context.logger.log("Test cron job executed");

Copilot uses AI. Check for mistakes.

export const NodeCronAdapter = (): CronAdapter => {
return {
schedule() {},
Copy link

Copilot AI Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schedule method is empty and doesn't implement any functionality. This will cause CRON jobs to not be scheduled when using the NodeCronAdapter.

Copilot uses AI. Check for mistakes.
Comment on lines 24 to 30
},
},
handler: c => {
// biome-ignore lint/suspicious/noConsole: needed for testing cron functionality
console.log("Cron job triggered", c.get("core").cron);

return c.text("Not implemented", 200);
Copy link

Copilot AI Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route returns 'Not implemented' with a 200 status code. This should either return a proper implementation or use a 501 status code to indicate the feature is not implemented.

Suggested change
},
},
handler: c => {
// biome-ignore lint/suspicious/noConsole: needed for testing cron functionality
console.log("Cron job triggered", c.get("core").cron);
return c.text("Not implemented", 200);
501: {
content: {
"text/plain": {
schema: z.string(),
},
},
description: "Not implemented",
},
},
},
handler: c => {
// biome-ignore lint/suspicious/noConsole: needed for testing cron functionality
console.log("Cron job triggered", c.get("core").cron);
return c.text("Not implemented", 501);

Copilot uses AI. Check for mistakes.
@aXenDeveloper
Copy link
Owner Author

@codex make code review. Find issue about performerce.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines 167 to 178
plugins: plugins.map(plugin => ({
id: plugin.pluginId,
})),
cron: plugins.flatMap(plugin =>
plugin.cronJobs.map(cronJob => ({
pluginId: plugin.pluginId,
module: cronJob.module,
name: cronJob.name,
schedule: cronJob.schedule,
handler: cronJob.handler,
description: cronJob.description,
})),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Avoid rebuilding cron metadata on every request

The global middleware rebuilds the list of cron jobs on every request by calling plugins.flatMap and map even though the set of plugins and cron definitions is static for the lifetime of the server. This allocates a new array of job objects and rewraps each handler for every request, adding avoidable work on all API traffic. Consider computing the cron metadata once when the middleware is created and reusing the same reference instead of recalculating it per request, especially if many cron jobs are registered.

Useful? React with 👍 / 👎.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex Can you fix this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Testing

  • ⚠️ pnpm lint (fails: formatting issues in unrelated files)
  • pnpm lint packages/vitnode/src/api/middlewares/global.middleware.ts
  • pnpm test

View task →

@aXenDeveloper aXenDeveloper marked this pull request as ready for review September 6, 2025 10:39
@aXenDeveloper aXenDeveloper merged commit 4ed4e16 into canary Sep 6, 2025
3 of 4 checks passed
@aXenDeveloper aXenDeveloper deleted the cron_jobs branch September 6, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💡 Feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants