@lenne.tech/nest-server 11.26.3 → 11.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1591,6 +1591,17 @@ export interface IServerOptions {
1591
1591
  */
1592
1592
  env?: string;
1593
1593
 
1594
+ /**
1595
+ * Semantic version of the running build (e.g. from package.json / meta.json).
1596
+ *
1597
+ * Surfaced via the build-identity health indicator alongside the commit SHA.
1598
+ * Unlike the commit (which uniquely pins the exact build), the version is a
1599
+ * rarely-bumped semver and may legitimately differ between API and frontend.
1600
+ *
1601
+ * @since 11.27.0
1602
+ */
1603
+ version?: string;
1604
+
1594
1605
  /**
1595
1606
  * Configuration for the error code module
1596
1607
  *
@@ -1671,6 +1682,24 @@ export interface IServerOptions {
1671
1682
  * Configuration of single health checks
1672
1683
  */
1673
1684
  configs?: {
1685
+ /**
1686
+ * Configuration for the build-identity health indicator.
1687
+ *
1688
+ * Always reports status "up" and surfaces the running build's commit SHA,
1689
+ * version and environment under the health check's `info`/`details`, so a
1690
+ * drifted / stale container can be detected after a partial rollout. The
1691
+ * commit is read from `process.env.APP_VERSION_COMMIT` (baked at build
1692
+ * time from the CI commit SHA); `version` comes from {@link IServerOptions.version}.
1693
+ *
1694
+ * @since 11.27.0
1695
+ */
1696
+ build?: {
1697
+ /**
1698
+ * Whether to include build identity in the health check (default: true)
1699
+ */
1700
+ enabled?: boolean;
1701
+ };
1702
+
1674
1703
  /**
1675
1704
  * Configuration for database health check
1676
1705
  */
@@ -9,6 +9,7 @@ import {
9
9
  import type { MongoosePingCheckSettings } from '@nestjs/terminus/dist/health-indicator/database/mongoose.health.js';
10
10
  import type { DiskHealthIndicatorOptions } from '@nestjs/terminus/dist/health-indicator/disk/disk-health-options.type.js';
11
11
 
12
+ import { getBuildInfo } from '../../common/helpers/meta.helper';
12
13
  import { ConfigService } from '../../common/services/config.service';
13
14
 
14
15
  /**
@@ -64,6 +65,18 @@ export class CoreHealthCheckService {
64
65
  ),
65
66
  );
66
67
  }
68
+ // Build identity (commit / version / env) — always reported as "up", so it
69
+ // surfaces under `info`/`details` without ever affecting the overall health
70
+ // status. Lets ops/monitoring detect a drifted or stale container after a
71
+ // partial rollout (the same commit-SHA signal the admin UI compares). The
72
+ // commit is baked into the image at build time (APP_VERSION_COMMIT, fed from
73
+ // the CI commit SHA); `version`/`env` come from the config. Opt out with
74
+ // `healthCheck.configs.build.enabled: false`.
75
+ if (this.config.get<boolean>('healthCheck.configs.build.enabled') !== false) {
76
+ const build = getBuildInfo({ env: this.config.get<string>('env'), version: this.config.get<string>('version') });
77
+ healthIndicatorFunctions.push(async () => ({ build: { ...build, status: 'up' as const } }));
78
+ }
79
+
67
80
  return this.health.check(healthIndicatorFunctions);
68
81
  }
69
82
  }
package/src/index.ts CHANGED
@@ -40,6 +40,7 @@ export * from './core/common/helpers/interceptor.helper';
40
40
  export * from './core/common/helpers/gridfs.helper';
41
41
  export * from './core/common/helpers/input.helper';
42
42
  export * from './core/common/helpers/logging.helper';
43
+ export * from './core/common/helpers/meta.helper';
43
44
  export * from './core/common/helpers/model.helper';
44
45
  export * from './core/common/helpers/register-enum.helper';
45
46
  export * from './core/common/helpers/scim.helper';