-
Notifications
You must be signed in to change notification settings - Fork 7
Staging to Master #61
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
base: master
Are you sure you want to change the base?
Conversation
env optimizations
updated cli package
master to develop
Health-check
added-redis
API-DOC-for-health-check
WalkthroughAdds a health-check feature: API docs and Postman collection include Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application (src/app.js)
participant Env as Env Validator (src/envVariables.js)
participant HealthInit as Health Init (src/healthCheck/index.js)
participant Router as Express Router
participant HCService as Health Service (src/healthCheck/health-check.js)
participant Redis as Redis
App->>Env: run validation()
alt success
Env-->>App: { success: true }
App->>HealthInit: initialize(app)
HealthInit->>Router: register /health, /healthCheckStatus
else failure
Env-->>App: { success: false }
App->>App: log error and exit
end
Note over Router,HCService: runtime request flow
Router->>HCService: GET /health
HCService->>Redis: perform Redis check (via configured URL)
alt Redis reachable
Redis-->>HCService: OK
HCService-->>Router: 200 { healthy: true, details... }
else Redis failure
Redis-->>HCService: error
HCService-->>Router: 400/500 { healthy: false, error... }
end
Router-->>Client: health response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 6
🧹 Nitpick comments (6)
src/healthCheck/health.config.js (1)
8-18: Avoid hardcoding service version in health config.Config shape looks correct, but
version: '1.0.0'will easily drift from the real service version. Prefer deriving this frompackage.jsonor an env variable so health responses always report the actual deployed version. Optionally, consider drivingredis.enabledfrom configuration as well.src/healthCheck/README.md (1)
1-135: Fix package name in docs and address markdown tab formatting.
- The README refers to
elevate-project-services-health-checkon line 3, butsrc/package.jsondeclares the dependency aselevate-services-health-check. Update the README to match the actual package name.- Hard tabs appear in code block examples (lines 23–27, 72–86, 120–127). Replace these with spaces to comply with markdownlint (MD010).
src/envVariables.js (2)
3-4: Make the validator idempotent by scopingsuccessandtableDatainside the functionBecause
successandtableDataare module‑level variables, multiple calls to the exported function will:
- Keep
successstuck infalseonce any run has failed, even if later runs pass.- Keep accumulating rows in
tableData, duplicating table entries on each call.For a startup‑time check this might be acceptable today, but making the validator idempotent will avoid surprises if it’s ever reused (e.g., in a health/self‑check).
Consider:
- Initializing
let success = trueandlet tableData = new table()insidemodule.exports = function () { ... }.- Optionally treating
enviromentVariablesas immutable (e.g., don’t permanently flip.optionalbased onrequiredIf, or clone before mutating) so repeated invocations see a clean schema.Also applies to: 56-57, 98-138
26-30: AlignDISABLE_LOGdefault type and messaging with downstream expectations
DISABLE_LOGhas:
- Message: “Required true or false for logs”
- Default:
true(boolean)Elsewhere in the app this env var may be read as a string (
'true'/'false') fromprocess.env, but the default here assigns a boolean. That type mismatch can cause subtle issues in strict comparisons or config loaders.Consider:
- Making the default a string (
'true'/'false') for consistency with typical env usage, or- Updating downstream code to treat it as a boolean consistently (and adjusting the message to reflect that).
Also applies to: 121-127
src/api-doc/api-doc.yaml (2)
450-460:operationIdfor/scheduler/jobs/updateDelayappears to be copy‑pastedThe
postoperation under/scheduler/jobs/updateDelaystill uses:operationId: /scheduler/jobs/createwhich doesn’t match the path and can confuse client generation and API documentation.
Update it to reflect the correct operation:
- operationId: /scheduler/jobs/create + operationId: /scheduler/jobs/updateDelay
618-752: Clarify/scheduler/healthdescription and assign a meaningfuloperationIdFor the
/scheduler/healthGET:
- The description mentions mandatory request parameters and “This is a mandatory parameter”, but the operation defines no parameters.
operationIdis an empty string, which is awkward for tools that rely on it.You could simplify and correct this block as follows:
- description: >- - This API is used to verify the health status of the Scheduler Service - and its dependencies. - - * The API Endpoint for health check is /scheduler/health - - * It is mandatory to provide values for parameters that are marked as - `required` - - * This is a mandatory parameter and cannot be empty or null - operationId: '' + description: >- + This API is used to verify the health status of the Scheduler Service + and its dependencies. It performs a basic self-check of the scheduler + and downstream services such as Redis. + + * The API endpoint for health check is `/scheduler/health`. + * This endpoint does not accept any request parameters. + operationId: /scheduler/healthThis keeps the intent while removing references to non‑existent required parameters and making the operationId usable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
src/api-doc/MentorED-Scheduler.postman_collection.json(1 hunks)src/api-doc/api-doc.yaml(9 hunks)src/app.js(1 hunks)src/constants/interface-routes/configs.json(1 hunks)src/envVariables.js(1 hunks)src/healthCheck/README.md(1 hunks)src/healthCheck/health-check.js(1 hunks)src/healthCheck/health.config.js(1 hunks)src/healthCheck/index.js(1 hunks)src/package.json(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
src/healthCheck/index.js (2)
src/app.js (2)
require(7-7)app(24-24)src/healthCheck/health-check.js (1)
require(9-9)
src/app.js (1)
src/healthCheck/health-check.js (1)
require(9-9)
src/envVariables.js (1)
src/configs/bull.js (1)
process(4-4)
src/healthCheck/health-check.js (1)
src/app.js (1)
require(7-7)
src/healthCheck/health.config.js (1)
src/configs/bull.js (1)
process(4-4)
🪛 markdownlint-cli2 (0.18.1)
src/healthCheck/README.md
23-23: Hard tabs
Column: 1
(MD010, no-hard-tabs)
24-24: Hard tabs
Column: 1
(MD010, no-hard-tabs)
25-25: Hard tabs
Column: 1
(MD010, no-hard-tabs)
26-26: Hard tabs
Column: 1
(MD010, no-hard-tabs)
27-27: Hard tabs
Column: 1
(MD010, no-hard-tabs)
72-72: Hard tabs
Column: 1
(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1
(MD010, no-hard-tabs)
74-74: Hard tabs
Column: 1
(MD010, no-hard-tabs)
75-75: Hard tabs
Column: 1
(MD010, no-hard-tabs)
76-76: Hard tabs
Column: 1
(MD010, no-hard-tabs)
77-77: Hard tabs
Column: 1
(MD010, no-hard-tabs)
78-78: Hard tabs
Column: 1
(MD010, no-hard-tabs)
79-79: Hard tabs
Column: 1
(MD010, no-hard-tabs)
80-80: Hard tabs
Column: 1
(MD010, no-hard-tabs)
81-81: Hard tabs
Column: 1
(MD010, no-hard-tabs)
82-82: Hard tabs
Column: 1
(MD010, no-hard-tabs)
83-83: Hard tabs
Column: 1
(MD010, no-hard-tabs)
84-84: Hard tabs
Column: 1
(MD010, no-hard-tabs)
85-85: Hard tabs
Column: 1
(MD010, no-hard-tabs)
86-86: Hard tabs
Column: 1
(MD010, no-hard-tabs)
120-120: Hard tabs
Column: 1
(MD010, no-hard-tabs)
121-121: Hard tabs
Column: 1
(MD010, no-hard-tabs)
122-122: Hard tabs
Column: 1
(MD010, no-hard-tabs)
123-123: Hard tabs
Column: 1
(MD010, no-hard-tabs)
124-124: Hard tabs
Column: 1
(MD010, no-hard-tabs)
125-125: Hard tabs
Column: 1
(MD010, no-hard-tabs)
126-126: Hard tabs
Column: 1
(MD010, no-hard-tabs)
127-127: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🔇 Additional comments (1)
src/package.json (1)
14-32: Verifycli-tableandelevate-services-health-checkpackage legitimacy and security status.Both packages exist on npm at the specified versions (0.3.11 and 0.0.4 respectively). However, confirm that
elevate-services-health-checkis the correct scoped/internal package for this project and check both packages for known vulnerabilities before merging.
… validation operators
fix: exit with error code when environment variables are missing; add…
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: 3
🧹 Nitpick comments (2)
src/envVariables.js (2)
5-54: Typo in variable name and minor formatting issue.
- Line 5:
enviromentVariablesshould beenvironmentVariables(missing 'n').- Line 39: Missing space after colon in
default:'notificationtopic'.Apply this diff to fix both issues:
-let enviromentVariables = { +let environmentVariables = { API_DOC_URL: { message: 'Required api doc url', optional: true, default: '/scheduler/api-doc', }, APPLICATION_BASE_URL: { message: 'Required application base url', optional: true, default: '/scheduler/', }, APPLICATION_PORT: { message: 'Required application port number', optional: true, default: '4000' }, DEFAULT_QUEUE: { message: 'Required queue name', optional: true, default: 'emailqueue', }, DISABLE_LOG: { message: 'Required true or false for logs', optional: true, default: true, }, ERROR_LOG_LEVEL: { message: 'Required error log level', optional: true, default: 'silly' }, NOTIFICATION_KAFKA_TOPIC: { message: 'Required notification topic', optional: true, - default:'notificationtopic' + default: 'notificationtopic' }, KAFKA_URL: { message: 'Required kafka url', optional: false, }, REDIS_HOST: { message: 'Required redis host', optional: false, }, REDIS_PORT: { message: 'Required redis port number', optional: false, }, }Note: You'll also need to update all references to
enviromentVariablesthroughout the file.
129-135: Add undefined/null check for message.Line 130 checks if
message !== ''but doesn't verify thatmessageis defined. If the message property is undefined or null, the check would pass but line 131 would fail.Apply this diff:
if (!keyCheckPass) { - if (enviromentVariables[eachEnvironmentVariable].message !== '') { + if (enviromentVariables[eachEnvironmentVariable].message && enviromentVariables[eachEnvironmentVariable].message !== '') { tableObj[eachEnvironmentVariable] = enviromentVariables[eachEnvironmentVariable].message } else { tableObj[eachEnvironmentVariable] = `FAILED - ${eachEnvironmentVariable} is required` } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app.js(1 hunks)src/envVariables.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/app.js
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: priyanka-TL
Repo: ELEVATE-Project/scheduler PR: 61
File: src/healthCheck/index.js:8-27
Timestamp: 2025-12-03T11:02:00.466Z
Learning: In the ELEVATE-Project/scheduler repository, health check routes in src/healthCheck/index.js are defined without the /scheduler prefix (e.g., /health) because the prefix is added at a different layer such as app mounting, reverse proxy, or API gateway configuration.
🔇 Additional comments (1)
src/envVariables.js (1)
1-3: Previous critical issue resolved.The
validRequiredIfOperatorsdeclaration fixes the ReferenceError that was flagged in the previous review.
Summary by CodeRabbit
New Features
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.