{"_id":"@croco/health-core","_rev":"2-0a5c4f03429f5fd493d01524d9f296e6","name":"@croco/health-core","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@croco/health-core","version":"0.0.1","_id":"@croco/health-core@0.0.1","maintainers":[{"name":"kang-heewon","email":"heewon.dev@gmail.com"},{"name":"ddark","email":"ddark.kr@gmail.com"}],"dist":{"shasum":"b6e4981e449aa0657312959a4356e7fb984d52aa","tarball":"https://registry.npmjs.org/@croco/health-core/-/health-core-0.0.1.tgz","fileCount":6,"integrity":"sha512-fbVtKSragsVAm4Ei1Xge5OxGTn+CAb+Gjn8L6udoE7t++y5jzlSYiiBXDNb9/ZcSsN4e/3ncae7t+zfOg/7WpA==","signatures":[{"sig":"MEUCIFeXM1LRRmBgp7RNQXsAOiXNfJycvQSDg3xvZSK8BRWeAiEAosOGscaR+hDG62HZ/Kmq7GMtNUORNJUQckE5b/Csako=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11234},"main":"./dist/index.js","type":"commonjs","_from":"file:croco-health-core-0.0.1.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"lint":"oxlint .","test":"vitest run","build":"tsup src/index.ts --format esm,cjs --minify --clean --dts","deploy":"pnpm run build && pnpm publish --no-git-checks","typecheck":"tsc --noEmit"},"_npmUser":{"name":"kang-heewon","email":"heewon.dev@gmail.com"},"_resolved":"/tmp/1fd3416dce508c3ed5c4a27767b04156/croco-health-core-0.0.1.tgz","_integrity":"sha512-fbVtKSragsVAm4Ei1Xge5OxGTn+CAb+Gjn8L6udoE7t++y5jzlSYiiBXDNb9/ZcSsN4e/3ncae7t+zfOg/7WpA==","_npmVersion":"10.9.7","description":"Health check monitoring system for Croco applications.","directories":{},"_nodeVersion":"22.22.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/health-core_0.0.1_1778834260837_0.6397847114478352","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@croco/health-core","version":"0.0.2","type":"commonjs","main":"./dist/index.js","types":"./dist/index.d.ts","publishConfig":{"access":"public"},"devDependencies":{},"scripts":{"build":"tsup src/index.ts --format esm,cjs --minify --clean --dts","deploy":"pnpm run build && pnpm publish --no-git-checks","lint":"oxlint .","test":"vitest run","typecheck":"tsc --noEmit"},"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"}},"_id":"@croco/health-core@0.0.2","description":"Health check monitoring system for Croco applications.","_integrity":"sha512-6BlMI+IMjB04GzskTKULeLblxHy1LxEJrxw+GMis2OcDDJ0n4/6PcgM30uofjonVfZU8VR0Sx2CxruU6tm4tlQ==","_resolved":"/private/var/folders/zp/px4pj6gs20q8c38hgmbym1080000gn/T/2a8a53bbda6694f90883585c5d1abb80/croco-health-core-0.0.2.tgz","_from":"file:croco-health-core-0.0.2.tgz","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-6BlMI+IMjB04GzskTKULeLblxHy1LxEJrxw+GMis2OcDDJ0n4/6PcgM30uofjonVfZU8VR0Sx2CxruU6tm4tlQ==","shasum":"d03f6bd80680af71f40fd0a358c01cdd0c993675","tarball":"https://registry.npmjs.org/@croco/health-core/-/health-core-0.0.2.tgz","fileCount":6,"unpackedSize":11234,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD2ORvxr3P4u944Vl+j5C8MEFrvn7vh7uBvPEy3W9fAAAIgGOMSXiQSQA7P0mPgIbFLnumCqLght1lvaDPbP8HfAt4="}]},"_npmUser":{"name":"kang-heewon","email":"heewon.dev@gmail.com"},"directories":{},"maintainers":[{"name":"kang-heewon","email":"heewon.dev@gmail.com"},{"name":"ddark","email":"ddark.kr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/health-core_0.0.2_1780294540729_0.5205443382763961"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-15T08:37:40.695Z","modified":"2026-06-01T06:15:41.031Z","0.0.1":"2026-05-15T08:37:40.974Z","0.0.2":"2026-06-01T06:15:40.892Z"},"description":"Health check monitoring system for Croco applications.","maintainers":[{"name":"kang-heewon","email":"heewon.dev@gmail.com"},{"name":"ddark","email":"ddark.kr@gmail.com"}],"readme":"# @croco/health-core\n\nHealth check monitoring system for Croco applications.\n\n## Features\n\n- **Type-safe health indicators** with detailed error and success reporting\n- **Parallel execution** of all health checks with configurable timeout\n- **AbortController support** for cancellable health checks\n- **Zero dependencies** — lightweight and fast\n\n## Installation\n\n```bash\npnpm add @croco/health-core\n```\n\n## Quick Start\n\n```typescript\nimport { HealthCheckService } from \"@croco/health-core\";\nimport type { HealthIndicator, HealthIndicatorResult } from \"@croco/health-core\";\n\nconst healthService = new HealthCheckService({ timeout: 5000 });\n\nclass DatabaseHealthIndicator implements HealthIndicator {\n  async check(signal?: AbortSignal): Promise<HealthIndicatorResult> {\n    try {\n      await this.db.ping();\n\n      return {\n        name: \"database\",\n        status: \"up\",\n        details: { latency: 15, connections: 5 },\n      };\n    } catch (error) {\n      return {\n        name: \"database\",\n        status: \"down\",\n        details: {\n          error: error instanceof Error ? error.message : String(error),\n          code: \"DB_CONNECTION_ERROR\",\n        },\n      };\n    }\n  }\n}\n\nhealthService.register(new DatabaseHealthIndicator());\n\nconst result = await healthService.check();\nconsole.log(result.status); // 'up' | 'down'\nconsole.log(result.results); // Array of individual check results\n```\n\n## API Reference\n\n### HealthIndicator\n\nInterface for implementing custom health checks.\n\n```typescript\ninterface HealthIndicator {\n  check(signal?: AbortSignal): Promise<HealthIndicatorResult>;\n}\n```\n\n### HealthIndicatorResult\n\nResult type returned by health checks.\n\n```typescript\ntype HealthIndicatorResult = {\n  name: string;\n  status: \"up\" | \"down\";\n  details?: HealthIndicatorErrorDetails | HealthIndicatorSuccessDetails;\n};\n```\n\n**Success details:**\n\n```typescript\ntype HealthIndicatorSuccessDetails = {\n  [key: string]: string | number | boolean | null | undefined;\n};\n```\n\nExample: `{ latency: 15, connections: 5, version: '1.2.3' }`\n\n**Error details:**\n\n```typescript\ntype HealthIndicatorErrorDetails = {\n  error: string;\n  message?: string;\n  code?: string;\n};\n```\n\nExample: `{ error: 'Connection timeout', code: 'ETIMEDOUT' }`\n\n### HealthCheckService\n\nOrchestrates health check execution.\n\n```typescript\nclass HealthCheckService {\n  constructor(options?: { timeout?: number });\n\n  register(indicator: HealthIndicator): void;\n  check(): Promise<HealthCheckResult>;\n}\n```\n\n## Examples\n\n### Database Health Check\n\n```typescript\nclass PostgresHealthIndicator implements HealthIndicator {\n  constructor(private readonly pool: Pool) {}\n\n  async check(): Promise<HealthIndicatorResult> {\n    try {\n      const start = Date.now();\n      await this.pool.query(\"SELECT 1\");\n      const latency = Date.now() - start;\n\n      return {\n        name: \"postgres\",\n        status: \"up\",\n        details: { latency, idleCount: this.pool.idleCount },\n      };\n    } catch (error) {\n      return {\n        name: \"postgres\",\n        status: \"down\",\n        details: { error: String(error), code: \"POSTGRES_ERROR\" },\n      };\n    }\n  }\n}\n```\n\n### Redis Health Check\n\n```typescript\nclass RedisHealthIndicator implements HealthIndicator {\n  constructor(private readonly redis: Redis) {}\n\n  async check(signal?: AbortSignal): Promise<HealthIndicatorResult> {\n    try {\n      const start = Date.now();\n      await this.redis.ping();\n      const latency = Date.now() - start;\n\n      return {\n        name: \"redis\",\n        status: \"up\",\n        details: { latency, connectedClients: await this.redis.client(\"LIST\") },\n      };\n    } catch (error) {\n      return {\n        name: \"redis\",\n        status: \"down\",\n        details: { error: String(error) },\n      };\n    }\n  }\n}\n```\n\n### External API Health Check\n\n```typescript\nclass ApiHealthIndicator implements HealthIndicator {\n  async check(signal?: AbortSignal): Promise<HealthIndicatorResult> {\n    try {\n      const response = await fetch(\"https://api.example.com/health\", {\n        signal,\n      });\n\n      if (!response.ok) {\n        return {\n          name: \"external-api\",\n          status: \"down\",\n          details: {\n            error: `HTTP ${response.status}`,\n            code: String(response.status),\n          },\n        };\n      }\n\n      return {\n        name: \"external-api\",\n        status: \"up\",\n        details: { latency: response.headers.get(\"X-Response-Time\") },\n      };\n    } catch (error) {\n      return {\n        name: \"external-api\",\n        status: \"down\",\n        details: { error: String(error) },\n      };\n    }\n  }\n}\n```\n\n## Integration with HTTP Endpoints\n\n```typescript\nimport { Hono } from \"hono\";\nimport { HealthCheckService } from \"@croco/health-core\";\n\nconst app = new Hono();\nconst healthService = new HealthCheckService();\n\nhealthService.register(new DatabaseHealthIndicator(db));\nhealthService.register(new RedisHealthIndicator(redis));\n\napp.get(\"/health\", async (c) => {\n  const result = await healthService.check();\n  return c.json(result, result.status === \"up\" ? 200 : 503);\n});\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}