-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update bootstrap.js adding check endaoment #1905
Conversation
WalkthroughThe pull request introduces new cron job functionality by adding two functions: Changes
Possibly related PRs
Suggested reviewers
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/server/bootstrap.ts
(2 hunks)
🔇 Additional comments (1)
src/server/bootstrap.ts (1)
74-74
: LGTM!The import follows the established pattern for cron job imports.
Let's verify the imported function exists and follows the cron job pattern:
✅ Verification successful
Implementation verified - follows all best practices
The imported function is properly implemented with:
- Configurable schedule via
CHECK_AND_UPDATE_ENDAOMENT_PROJECTS_CRONJOB_EXPRESSION
- Comprehensive error handling and logging
- Proper cron job scheduling pattern
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the imported cron job function exists and follows the pattern # Test: Check if the function exists and follows cron job patterns ast-grep --pattern $'export function runCheckAndUpdateEndaomentProject() { $$$ }'Length of output: 84
Script:
#!/bin/bash # First, locate the file fd "checkAndUpdateEndaomentProject.ts" # Try a more flexible pattern match ast-grep --pattern 'export function runCheckAndUpdateEndaomentProject' # Fallback to text search rg "runCheckAndUpdateEndaomentProject" -lLength of output: 289
Script:
#!/bin/bash # View the implementation cat src/services/cronJobs/checkAndUpdateEndaomentProject.ts # Look for related environment variables rg "ENDAOMENT" --type envLength of output: 3101
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/services/cronJobs/generateSitemapOnFrontend.ts (1)
Line range hint
28-34
: Fix template literal syntax errors in the axios request.The URL and Authorization header use incorrect template literal syntax that would cause runtime errors.
Apply this diff to fix the syntax:
- `{process.env.FRONTEND_URL}/api/generate-sitemap`, + `${process.env.FRONTEND_URL}/api/generate-sitemap`, { headers: { - Authorization: `Bearer {process.env.SITEMAP_CRON_SECRET}`, + Authorization: `Bearer ${process.env.SITEMAP_CRON_SECRET}`, }, },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/server/bootstrap.ts
(3 hunks)src/services/cronJobs/generateSitemapOnFrontend.ts
(1 hunks)
🔇 Additional comments (2)
src/services/cronJobs/generateSitemapOnFrontend.ts (1)
15-17
: LGTM! Well-implemented configurable cron schedule.The implementation properly retrieves the cron schedule from config with a sensible fallback to run every Sunday at midnight.
src/server/bootstrap.ts (1)
367-367
: Add environment variable control for the Endaoment cron job.The cron job lacks environment variable control for enabling/disabling, making it harder to control in different environments.
if (process.env.SITEMAP_CRON_SECRET !== '') { | ||
runGenerateSitemapOnFrontend(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve the environment variable check for the sitemap cron job.
The current check !== ''
is not a robust way to verify environment variables. It would treat 'false'
or '0'
as valid values.
Apply this diff to implement a more robust check:
- if (process.env.SITEMAP_CRON_SECRET !== '') {
+ if (process.env.SITEMAP_CRON_SECRET && process.env.ENABLE_SITEMAP_CRON === 'true') {
runGenerateSitemapOnFrontend();
}
This change:
- Ensures the secret exists
- Adds explicit control via
ENABLE_SITEMAP_CRON
- Follows the codebase pattern of using
=== 'true'
for feature flags
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (process.env.SITEMAP_CRON_SECRET !== '') { | |
runGenerateSitemapOnFrontend(); | |
} | |
if (process.env.SITEMAP_CRON_SECRET && process.env.ENABLE_SITEMAP_CRON === 'true') { | |
runGenerateSitemapOnFrontend(); | |
} |
Summary by CodeRabbit