Skip to content

Develop#32

Merged
Zaiidmo merged 23 commits intomasterfrom
develop
Apr 7, 2026
Merged

Develop#32
Zaiidmo merged 23 commits intomasterfrom
develop

Conversation

@saadmoumou
Copy link
Copy Markdown
Contributor

Summary

  • What does this PR change?

Why

  • Why is this change needed?

Checklist

  • Added/updated tests (if behavior changed)
  • npm run lint passes
  • npm run typecheck passes
  • npm test passes
  • npm run build passes
  • Added a changeset (npx changeset) if this affects consumers

Notes

  • Anything reviewers should pay attention to?

Zaiidmo and others added 20 commits March 29, 2026 12:47
…ckages

- Replace git tag --list strategy with package.json-driven tag validation
  in all 16 publish workflows; use git rev-parse to verify the exact tag
  exists rather than guessing the latest repo-wide tag
- Update error guidance to reflect feat/** → develop → master flow
- Standardize dependabot to npm-only, grouped, monthly cadence across
  all 16 packages; remove github-actions ecosystem updates
- Add missing dependabot.yml to AuthKit-UI, ChartKit-UI, HealthKit,
  HooksKit, paymentkit, StorageKit
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

* chore(config): set module to CommonJS and moduleResolution to Node for dist output

* chore(package): rename to @ciscode/health-kit

* chore(deps): update package-lock

* feat(indicators): add MongoHealthIndicator with ping command and timeout

* test(indicators): add MongoHealthIndicator unit tests (success/error/timeout)

* feat(services): add HealthService with Promise.allSettled orchestration

* test(services): add HealthService unit tests (liveness/readiness/concurrency)

* feat(controllers): add HealthController factory (GET live/ready, platform-agnostic)

* test(controllers): add HealthController unit tests (200 ok / 503 ServiceUnavailableException)

* feat(module): add HealthKitModule.register() dynamic module

* feat(exports): update public API exports for health-kit

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

* chore(config): set module to CommonJS and moduleResolution to Node for dist output

* chore(package): rename to @ciscode/health-kit

* chore(deps): update package-lock

* feat(indicators): add MongoHealthIndicator with ping command and timeout

* test(indicators): add MongoHealthIndicator unit tests (success/error/timeout)

* feat(services): add HealthService with Promise.allSettled orchestration

* test(services): add HealthService unit tests (liveness/readiness/concurrency)

* feat(controllers): add HealthController factory (GET live/ready, platform-agnostic)

* test(controllers): add HealthController unit tests (200 ok / 503 ServiceUnavailableException)

* feat(module): add HealthKitModule.register() dynamic module

* feat(exports): update public API exports for health-kit

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

* chore(config): set module to CommonJS and moduleResolution to Node for dist output

* chore(package): rename to @ciscode/health-kit

* chore(deps): update package-lock

* feat(indicators): add MongoHealthIndicator with ping command and timeout

* test(indicators): add MongoHealthIndicator unit tests (success/error/timeout)

* feat(services): add HealthService with Promise.allSettled orchestration

* test(services): add HealthService unit tests (liveness/readiness/concurrency)

* feat(controllers): add HealthController factory (GET live/ready, platform-agnostic)

* test(controllers): add HealthController unit tests (200 ok / 503 ServiceUnavailableException)

* feat(module): add HealthKitModule.register() dynamic module

* feat(exports): update public API exports for health-kit

* feat(indicators): add createIndicator inline factory with timeout support

* test(indicators): add createIndicator unit tests (true/false/void/throw/timeout)

* feat(indicators): add BaseHealthIndicator abstract class with result() helper

* test(indicators): add BaseHealthIndicator unit tests

* feat(decorators): add @healthindicator decorator for auto-registration by scope

* test(decorators): add @healthindicator decorator unit tests

* feat(module): extend HealthKitModule.register() with indicators[] option for DI-based auto-registration

* feat(exports): export createIndicator, BaseHealthIndicator, @healthindicator, HealthIndicatorScope

* chore(package): update description to mention MongoDB

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

* chore(config): set module to CommonJS and moduleResolution to Node for dist output

* chore(package): rename to @ciscode/health-kit

* chore(deps): update package-lock

* feat(indicators): add MongoHealthIndicator with ping command and timeout

* test(indicators): add MongoHealthIndicator unit tests (success/error/timeout)

* feat(services): add HealthService with Promise.allSettled orchestration

* test(services): add HealthService unit tests (liveness/readiness/concurrency)

* feat(controllers): add HealthController factory (GET live/ready, platform-agnostic)

* test(controllers): add HealthController unit tests (200 ok / 503 ServiceUnavailableException)

* feat(module): add HealthKitModule.register() dynamic module

* feat(exports): update public API exports for health-kit

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

* chore(config): set module to CommonJS and moduleResolution to Node for dist output

* chore(package): rename to @ciscode/health-kit

* chore(deps): update package-lock

* feat(indicators): add MongoHealthIndicator with ping command and timeout

* test(indicators): add MongoHealthIndicator unit tests (success/error/timeout)

* feat(services): add HealthService with Promise.allSettled orchestration

* test(services): add HealthService unit tests (liveness/readiness/concurrency)

* feat(controllers): add HealthController factory (GET live/ready, platform-agnostic)

* test(controllers): add HealthController unit tests (200 ok / 503 ServiceUnavailableException)

* feat(module): add HealthKitModule.register() dynamic module

* feat(exports): update public API exports for health-kit

* feat(indicators): add createIndicator inline factory with timeout support

* test(indicators): add createIndicator unit tests (true/false/void/throw/timeout)

* feat(indicators): add BaseHealthIndicator abstract class with result() helper

* test(indicators): add BaseHealthIndicator unit tests

* feat(decorators): add @healthindicator decorator for auto-registration by scope

* test(decorators): add @healthindicator decorator unit tests

* feat(module): extend HealthKitModule.register() with indicators[] option for DI-based auto-registration

* feat(exports): export createIndicator, BaseHealthIndicator, @healthindicator, HealthIndicatorScope

* chore(package): update description to mention MongoDB

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(config): add @interfaces/* and @indicators/* path aliases

* chore(config): rename eslint.config.js to .mjs to fix ESM loading

* chore(git): fix husky pre-commit hook for v10 compatibility

* feat(interfaces): add IHealthIndicator, HealthStatus, HealthIndicatorResult

* feat(indicators): add PostgresHealthIndicator (SELECT 1 + timeout)

* test(indicators): add PostgresHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add RedisHealthIndicator (PING + timeout)

* test(indicators): add RedisHealthIndicator unit tests (success/error/timeout)

* feat(indicators): add HttpHealthIndicator (GET + 2xx check + timeout)

* test(indicators): add HttpHealthIndicator unit tests (2xx/non-2xx/network/timeout)

* chore(deps): update package-lock after npm install

* fix(interfaces): add optional details field to HealthIndicatorResult

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* fix(services): rename indicators to results in HealthCheckResult response

* fix(tests): update health.service.spec to use results instead of indicators

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* fix(services): rename indicators to results in HealthCheckResult response

* fix(tests): update health.service.spec to use results instead of indicators

* chore(indicators): remove MongoHealthIndicator

* feat(module): make path optional with default 'health', add registerAsync

* feat(exports): remove MongoHealthIndicator, export HealthModuleAsyncOptions

* chore(package): add @nestjs/terminus peer dep, fix description

* chore(indicators): remove MongoHealthIndicator spec

* refactor(module): extract shared logic to eliminate code duplication

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* chore(indicators): remove MongoHealthIndicator spec

* test(module): add HealthKitModule spec - register, registerAsync, path default

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* fix(package): remove unused bundled dependencies (class-transformer, class-validator)

* chore(package): bump version to 0.1.0

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
- Rewrite README.md for @ciscode/health-kit (remove template content)
- Add register/registerAsync usage examples
- Document built-in indicators: PostgresHealthIndicator, RedisHealthIndicator, HttpHealthIndicator
- Document custom indicator APIs: createIndicator, BaseHealthIndicator + @healthindicator
- Add 200/503 response body examples
- Add API reference tables
- Add .changeset/health-kit-v0-1-0.md: minor bump (0.0.0 -> 0.1.0)
- Fix .changeset/config.json repo field to CISCODE-MA/HealthKit
- Set package.json version to 0.0.0 (changeset will bump to 0.1.0)

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
* docs(readme): rewrite README and add changeset for v0.1.0

- Rewrite README.md for @ciscode/health-kit (remove template content)
- Add register/registerAsync usage examples
- Document built-in indicators: PostgresHealthIndicator, RedisHealthIndicator, HttpHealthIndicator
- Document custom indicator APIs: createIndicator, BaseHealthIndicator + @healthindicator
- Add 200/503 response body examples
- Add API reference tables
- Add .changeset/health-kit-v0-1-0.md: minor bump (0.0.0 -> 0.1.0)
- Fix .changeset/config.json repo field to CISCODE-MA/HealthKit
- Set package.json version to 0.0.0 (changeset will bump to 0.1.0)

* chore(package): set version to 0.1.0

---------

Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
Co-authored-by: saad moumou <saad.moumou.coder@gmail.com>
Copy link
Copy Markdown

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 repurposes the NestJS module template into @ciscode/health-kit, adding a health-check module with liveness/readiness endpoints, built-in indicators, and supporting tooling/CI configuration.

Changes:

  • Added HealthKitModule + HealthService with /live and /ready endpoints and indicator orchestration.
  • Introduced built-in health indicators (Postgres/Redis/HTTP) plus APIs for custom indicators (createIndicator, BaseHealthIndicator, @HealthIndicator).
  • Updated repo configuration (TS path aliases, Jest thresholds/mappers, ESLint/lint-staged, workflows) to support the new package.

Reviewed changes

Copilot reviewed 35 out of 38 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
tsconfig.json Adds TS path aliases for new interfaces/ and indicators/ modules.
tsconfig.build.json Ensures build emits CommonJS with Node module resolution.
src/services/health.service.ts Implements indicator orchestration and aggregates results.
src/services/health.service.spec.ts Adds unit tests for liveness/readiness behavior and failure handling.
src/interfaces/health-indicator.interface.ts Defines health indicator contract and result types.
src/indicators/redis.indicator.ts Adds Redis PING-based health indicator.
src/indicators/redis.indicator.spec.ts Tests Redis indicator success/error/timeout cases.
src/indicators/postgres.indicator.ts Adds Postgres SELECT 1 health indicator.
src/indicators/postgres.indicator.spec.ts Tests Postgres indicator success/error/timeout cases.
src/indicators/http.indicator.ts Adds HTTP GET health indicator using fetch + AbortController timeout.
src/indicators/http.indicator.spec.ts Tests HTTP indicator for 2xx/non-2xx/network errors/timeouts.
src/indicators/create-indicator.ts Adds factory for inline custom indicators with timeout support.
src/indicators/create-indicator.spec.ts Tests createIndicator behaviors including timeout/rejections.
src/indicators/base.indicator.ts Adds base class helper for DI-based indicators.
src/indicators/base.indicator.spec.ts Tests BaseHealthIndicator result helper behavior.
src/index.ts Replaces template exports with health-kit public API exports.
src/health-kit.module.ts Adds dynamic module wiring for endpoints + indicator registration (sync/async).
src/health-kit.module.spec.ts Adds module-level tests for indicator registration and wiring.
src/decorators/health-indicator.decorator.ts Adds decorator to tag indicators for liveness/readiness routing.
src/decorators/health-indicator.decorator.spec.ts Tests decorator metadata behavior.
src/controllers/health.controller.ts Adds controller factory for configured health route prefix.
src/controllers/health.controller.spec.ts Tests controller behavior and 503 handling.
README.md Replaces template README with package docs and usage examples.
package.json Renames package, updates metadata/peers, keeps Changesets-based release scripts.
package-lock.json Updates lockfile package name and dependency metadata.
lint-staged.config.mjs Adds lint-staged config for prettier + eslint.
jest.config.ts Raises global coverage thresholds and adds new moduleNameMapper aliases.
eslint.config.mjs Updates ESLint flat config, adds import rules, sets ignores.
eslint.config.js Removes duplicate/old ESLint config file.
CHANGELOG.md Adds initial changelog for @ciscode/health-kit v0.1.0.
.husky/pre-commit Simplifies pre-commit hook to run lint-staged.
.github/workflows/release-check.yml Updates CI checks and makes Sonar steps unconditional + status reporting.
.github/workflows/publish.yml Updates publish trigger and adds tag validation + provenance publishing.
.github/workflows/pr-validation.yml Bumps Node version for PR validation workflow.
.github/dependabot.yml Adds Dependabot config for npm dependencies.
.github/CODEOWNERS Adds CODEOWNERS entry for repository.
.changeset/thick-maps-raise.md Removes an old template changeset.
.changeset/config.json Updates Changesets repo metadata to HealthKit.

Comment on lines +131 to +137
private static _resolveIndicatorClasses(indicators: Type<BaseHealthIndicator>[]) {
const livenessClasses = indicators.filter(
(cls) => Reflect.getMetadata(HEALTH_INDICATOR_METADATA, cls) === "liveness",
);
const readinessClasses = indicators.filter(
(cls) => Reflect.getMetadata(HEALTH_INDICATOR_METADATA, cls) === "readiness",
);
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This module calls Reflect.getMetadata(...) below; without importing reflect-metadata in this file, consumers that import HealthKitModule via a deep import (or before the package entrypoint runs) can hit Reflect.getMetadata is not a function at runtime. Import reflect-metadata here (or switch to Nest’s metadata helpers such as SetMetadata/Reflector) to make the module self-contained.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +54
* import { HealthModule } from '@ciscode/health-kit';
* import { MongoHealthIndicator } from '@ciscode/health-kit';
*
* @Module({
* imports: [
* HealthModule.register({
* path: 'health',
* liveness: [],
* readiness: [new MongoHealthIndicator(dataSource)],
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The JSDoc example uses HealthModule/MongoHealthIndicator, but the exported module in this package is HealthKitModule and there is no MongoHealthIndicator in this PR. Please update the example to reflect the actual public API so consumers don’t copy/paste broken code.

Suggested change
* import { HealthModule } from '@ciscode/health-kit';
* import { MongoHealthIndicator } from '@ciscode/health-kit';
*
* @Module({
* imports: [
* HealthModule.register({
* path: 'health',
* liveness: [],
* readiness: [new MongoHealthIndicator(dataSource)],
* import { Module } from '@nestjs/common';
* import { HealthKitModule } from '@ciscode/health-kit';
*
* @Module({
* imports: [
* HealthKitModule.register({
* path: 'health',
* liveness: [],
* readiness: [],

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +44
const results: HealthIndicatorResult[] = settled.map((outcome, idx) => {
if (outcome.status === "fulfilled") return outcome.value;
// A thrown exception counts as "down"
return {
name: indicators[idx]?.constructor.name ?? `indicator-${idx}`,
status: "down" as const,
message: outcome.reason instanceof Error ? outcome.reason.message : "Unknown error",
};
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

When an indicator rejects/throws, the fallback name uses constructor.name, which will be unhelpful for factory-created indicators (e.g. createIndicator(...) returns a plain object so this becomes "Object"). Consider preferring an optional name property on the indicator instance (if present) or extending IHealthIndicator to include a name field, so failures are attributed correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +13
* The check function may return:
* - `false` → indicator reports `"down"`
* - `true` or `void` → indicator reports `"up"`
* - throws → indicator reports `"down"` with the error message
*
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The docs say "throws → indicator reports "down" with the error message", but check() currently lets exceptions/timeout rejections bubble (the returned promise rejects) instead of resolving a { status: 'down', message } result. Either adjust the docstring to match the current behavior or catch errors and return a down result (consistent with the built-in indicators).

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +18
// ÔöÇÔöÇ Fixtures ÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇÔöÇ

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This test file contains garbled/invalid characters in comment separators (e.g. ÔöÇÔöÇ ...). This is likely an encoding artifact and should be replaced with normal ASCII so diffs remain readable and tooling doesn’t choke on non-UTF8 sequences.

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +55
- name: Validate version tag and package.json
run: |
PKG_VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')
TAG="v${PKG_VERSION}"

if [[ -z "$PKG_VERSION" ]]; then
echo "❌ ERROR: Could not read version from package.json"
exit 1
fi

if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ ERROR: Invalid version format in package.json: '$PKG_VERSION'"
echo "Expected format: x.y.z (e.g., 1.0.0, 0.2.3)"
exit 1
fi

if ! git rev-parse "$TAG" >/dev/null 2>&1; then
echo "❌ ERROR: Tag $TAG not found!"
echo ""
echo "This typically happens when:"
echo " 1. You forgot to run 'npm version patch|minor|major' on your feature branch"
echo " 2. You didn't push the tag: git push origin <feat/your-feature> --tags"
echo " 3. The tag was created locally but never pushed to remote"
echo ""
echo "📋 Correct workflow:"
echo " 1. On feat/** or feature/**: npm version patch (or minor/major)"
echo " 2. Push branch + tag: git push origin feat/your-feature --tags"
echo " 3. PR feat/** → develop, then PR develop → master"
echo " 4. Workflow automatically triggers on master push"
echo ""
exit 1
fi

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This publish workflow requires a v${package.json version} git tag to already exist, but the repo’s release flow uses Changesets (npm run release / changeset publish) which does not inherently create git tags. Unless tagging is guaranteed elsewhere, this step will block publishes; consider removing the tag requirement or generating/verifying tags as part of the Changesets release process instead.

Copilot uses AI. Check for mistakes.
Comment on lines 57 to 75
- name: SonarCloud Scan
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sonar == 'true' }}
uses: SonarSource/sonarqube-scan-action@v6
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }}
with:
args: >
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }} \
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \
-Dsonar.sources=src \
-Dsonar.tests=test \
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }}
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }}
-Dsonar.sources=src
-Dsonar.tests=test
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info

- name: SonarCloud Quality Gate
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sonar == 'true' }}
uses: SonarSource/sonarqube-quality-gate-action@v1
timeout-minutes: 10
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

SonarCloud scan/quality gate now runs unconditionally on every PR to master. For PRs from forks, SONAR_TOKEN is not provided by GitHub, so these steps will fail and block merges. Add a guard (e.g. only run when secrets.SONAR_TOKEN is available or when the PR is from the same repo).

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +59
async check(): Promise<HealthIndicatorResult> {
try {
await Promise.race([this.client.ping(), this._timeout()]);
return { name: "redis", status: "up" };
} catch (error) {
return {
name: "redis",
status: "down",
message: error instanceof Error ? error.message : "Unknown error",
};
}
}

private _timeout(): Promise<never> {
return new Promise((_, reject) =>
setTimeout(() => reject(new Error("Timeout")), this.timeoutMs),
);
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

Promise.race([ping, this._timeout()]) leaves the setTimeout pending even when ping() resolves quickly. This creates unnecessary timers (and can keep the event loop busy under frequent checks). Consider implementing a timeout helper that clearTimeouts on completion (similar to the HTTP indicator’s finally { clearTimeout(...) }).

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +58
async check(): Promise<HealthIndicatorResult> {
try {
await Promise.race([this.client.query("SELECT 1"), this._timeout()]);
return { name: "postgres", status: "up" };
} catch (error) {
return {
name: "postgres",
status: "down",
message: error instanceof Error ? error.message : "Unknown error",
};
}
}

private _timeout(): Promise<never> {
return new Promise((_, reject) =>
setTimeout(() => reject(new Error("Timeout")), this.timeoutMs),
);
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

Same as Redis indicator: the timeout created in _timeout() is never cleared when the query succeeds, so each successful check still schedules a timer until it fires. Consider using a clearTimeout-based helper (or AbortSignal where applicable) to avoid accumulating unnecessary timers.

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +43
const timeoutPromise = new Promise<never>((_, reject) =>
setTimeout(() => reject(new Error(`${name} timed out after ${timeout}ms`)), timeout),
);

return Promise.race([run(), timeoutPromise]);
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The timeout setTimeout(...) is never cleared when run() finishes first, so successful indicators still leave a pending timer until it fires. Consider keeping the timeout handle and clearing it once run() settles to avoid unnecessary timers during frequent health checks.

Suggested change
const timeoutPromise = new Promise<never>((_, reject) =>
setTimeout(() => reject(new Error(`${name} timed out after ${timeout}ms`)), timeout),
);
return Promise.race([run(), timeoutPromise]);
let timeoutHandle: ReturnType<typeof setTimeout>;
const timeoutPromise = new Promise<never>((_, reject) => {
timeoutHandle = setTimeout(() => reject(new Error(`${name} timed out after ${timeout}ms`)), timeout);
});
const runPromise = run().finally(() => clearTimeout(timeoutHandle));
return Promise.race([runPromise, timeoutPromise]);

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

@Zaiidmo Zaiidmo merged commit 968ba8c into master Apr 7, 2026
10 of 11 checks passed
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.

3 participants