@visulima/health-check 2.0.13 → 2.0.14
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.
- package/CHANGELOG.md +30 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +137 -137
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
## @visulima/health-check [2.0.14](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.13...@visulima/health-check@2.0.14) (2024-06-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* allow node v22 ([890d457](https://github.com/visulima/visulima/commit/890d4570f18428e2463944813c0c638b3f142803))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Styles
|
|
10
|
+
|
|
11
|
+
* cs fixes on some package.json files ([12fc0f7](https://github.com/visulima/visulima/commit/12fc0f74e206cef77863b0b89ec41174ca9ff0bd))
|
|
12
|
+
* disabled noPropertyAccessFromIndexSignature ([#386](https://github.com/visulima/visulima/issues/386)) ([2250c02](https://github.com/visulima/visulima/commit/2250c02b870a5b37d78d01365105a0777c5728e2))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Miscellaneous Chores
|
|
16
|
+
|
|
17
|
+
* changed semantic-release-npm to pnpm ([b6d100a](https://github.com/visulima/visulima/commit/b6d100a2bf3fd026577be48726a37754947f0973))
|
|
18
|
+
* **deps:** updated dev deps ([d91ac38](https://github.com/visulima/visulima/commit/d91ac389cea85a6c6bdc8de97905252a6c467abc))
|
|
19
|
+
* downgrade eslint-plugin-vitest ([0162771](https://github.com/visulima/visulima/commit/0162771e6022e4594486a796bc41e91a2d87bcd8))
|
|
20
|
+
* **health-check:** fixed dns tests ([3214e32](https://github.com/visulima/visulima/commit/3214e32291138b039b1d531c9a6818ecc9850af3))
|
|
21
|
+
* update dev dependencies ([09c4854](https://github.com/visulima/visulima/commit/09c4854e221fa8b808dfe66d7196d8db2a39b366))
|
|
22
|
+
* updated dev dependencies ([a2e0504](https://github.com/visulima/visulima/commit/a2e0504dc239049434c2482756ff15bdbaac9b54))
|
|
23
|
+
* updated dev dependencies ([abd319c](https://github.com/visulima/visulima/commit/abd319c23576aa1dc751ac874e806bddbc977d51))
|
|
24
|
+
* updated dev dependencies ([0767afe](https://github.com/visulima/visulima/commit/0767afe9be83da6698c1343724400171f952599e))
|
|
25
|
+
* updated dev dependencies ([d7791e3](https://github.com/visulima/visulima/commit/d7791e327917e438757636573b1e5549a97bba7b))
|
|
26
|
+
* updated dev dependencies ([6005345](https://github.com/visulima/visulima/commit/60053456717a3889fc77b4fb5b05d50a662475b2))
|
|
27
|
+
* updated dev dependencies ([87dee15](https://github.com/visulima/visulima/commit/87dee156e797b5dee2557a09ad32c935d851847c))
|
|
28
|
+
* updated dev dependencies ([bf2c635](https://github.com/visulima/visulima/commit/bf2c635859601cc97858226e70f47219eabc213e))
|
|
29
|
+
* updated dev dependencies ([f67c7f1](https://github.com/visulima/visulima/commit/f67c7f14ecc328ed91d06d01ac6514e8bce72cb4))
|
|
30
|
+
|
|
1
31
|
## @visulima/health-check [2.0.13](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.12...@visulima/health-check@2.0.13) (2024-03-27)
|
|
2
32
|
|
|
3
33
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/checks/dns-check.ts","../src/checks/http-check.ts","../src/checks/node-environment-check.ts","../src/checks/ping-check.ts","../src/handler/healthcheck.ts","../src/handler/readyhandler.ts","../src/healthcheck.ts"],"names":["CacheableLookup","DISPLAY_NAME","dnsCheck","host","expectedAddresses","options","family","hints","config","cacheable","meta","error","dns_check_default","deepStrictEqual","httpCheck","response","textBody","http_check_default","nodeEnvironmentCheck","expectedEnvironment","environment","errorMessage","node_environment_check_default","ping","pingCheck","ping_check_default","StatusCodes","healthcheck_default","healthCheck","sendHeader","_","healthy","report","payload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AcA,EAAO,aAAeK,CAC/C,OAAS1B,EAAO,CACZqB,EAAS,CACL,YAAaK,EACb,OAAQ,CAAE,QAAS,GAAO,QAAU1B,EAAgB,QAAS,UAAW,IAAI,KAAK,EAAE,YAAY,CAAE,EACjG,KAAM,CAAE,MAAO,EAAK,CACxB,CACJ,CAGA,OAAA4B,EAAYF,CAAO,EAAIL,EAEhBA,EAAO,OAAO,OACzB,CACJ,EAEOL,EAAQS","sourcesContent":["import type { EntryObject, LookupOptions, Options } from \"cacheable-lookup\";\nimport CacheableLookup from \"cacheable-lookup\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"DNS check for\";\n\ninterface DnsOptions extends Options {\n family?: \"all\" | 4 | 6;\n hints?: number;\n}\n\n/**\n * Register the `dns` checker to ensure that a domain is reachable.\n */\nconst dnsCheck =\n (host: string, expectedAddresses?: string[], options?: DnsOptions): Checker =>\n async () => {\n const { family = \"all\", hints, ...config } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const cacheable = new CacheableLookup(config);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const meta: EntryObject = await cacheable.lookupAsync(host.replace(/^https?:\\/\\//, \"\"), {\n hints,\n ...(family === \"all\" ? { all: true } : { family }),\n } as LookupOptions);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument\n if (Array.isArray(expectedAddresses) && !expectedAddresses.includes(meta.address)) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n message: `${DISPLAY_NAME} ${host} returned address ${meta.address} instead of ${expectedAddresses.join(\", \")}.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} were resolved.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n },\n };\n }\n };\n\nexport default dnsCheck;\n","import { deepStrictEqual } from \"node:assert\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"HTTP check for\";\n\n/**\n * Register the `http` checker to ensure http body and status is correct.\n */\nconst httpCheck =\n (\n host: RequestInfo | URL,\n options?: {\n expected?: { body?: string; status?: number };\n fetchOptions?: RequestInit;\n },\n ): Checker =>\n async () => {\n try {\n // eslint-disable-next-line compat/compat\n const response = await fetch(host, options?.fetchOptions ?? {});\n\n if (options?.expected?.status !== undefined && options.expected.status !== response.status) {\n throw new Error(`${DISPLAY_NAME} ${host as string} returned status ${response.status} instead of ${options.expected.status}`);\n }\n\n if (options?.expected?.body !== undefined) {\n const textBody = await response.text();\n\n try {\n deepStrictEqual(textBody, options.expected.body);\n } catch {\n throw new Error(\n `${DISPLAY_NAME} ${host as string} returned body ${JSON.stringify(textBody)} instead of ${JSON.stringify(options.expected.body)}`,\n );\n }\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host as string} was successful.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n status: response.status,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n },\n };\n }\n };\n\nexport default httpCheck;\n","import type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Node Environment Check\";\n\n/**\n * Register the `env` checker to ensure that `NODE_ENV` environment\n * variable is defined.\n */\nconst nodeEnvironmentCheck =\n (expectedEnvironment?: string): Checker =>\n async () => {\n const environment: string | undefined = process.env[\"NODE_ENV\"];\n\n let errorMessage: string | undefined;\n\n if (environment !== undefined && expectedEnvironment !== undefined && environment !== expectedEnvironment) {\n errorMessage = `NODE_ENV environment variable is set to \"${environment}\" instead of \"${expectedEnvironment}\".`;\n } else if (!environment) {\n errorMessage = [\"Missing NODE_ENV environment variable.\", \"It can make some parts of the application misbehave\"].join(\" \");\n }\n\n if (errorMessage !== undefined) {\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: false,\n message: errorMessage,\n timestamp: new Date().toISOString(),\n },\n };\n }\n\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: true,\n timestamp: new Date().toISOString(),\n },\n meta: {\n env: environment,\n },\n };\n };\n\nexport default nodeEnvironmentCheck;\n","import type { extendedPingOptions } from \"pingman\";\nimport ping from \"pingman\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Ping check for\";\n\n/**\n * Register the `ping` checker to ensure that a domain is reachable.\n */\nconst pingCheck =\n (host: string, options?: extendedPingOptions): Checker =>\n async () => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call\n const response = await ping(host.replace(/^https?:\\/\\//, \"\"), options);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (!response.alive) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: `Ping failed for ${host}.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} was successful.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n };\n }\n };\n\nexport default pingCheck;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck, HealthReport } from \"../types\";\n\nexport interface HealthCheckApiPayload {\n appName: string;\n appVersion: string;\n message: string;\n reports: HealthReport;\n status: \"error\" | \"ok\";\n timestamp: string;\n}\n\nexport default (healthCheck: HealthCheck, sendHeader: boolean | undefined = true) =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response): Promise<void> => {\n const { healthy, report } = await healthCheck.getReport();\n\n const payload: HealthCheckApiPayload = {\n appName: process.env[\"APP_NAME\"] ?? \"unknown\",\n appVersion: process.env[\"APP_VERSION\"] ?? \"unknown\",\n message: healthy ? \"Health check successful\" : \"Health check failed\",\n reports: report,\n status: healthy ? \"ok\" : \"error\",\n timestamp: new Date().toISOString(),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n response.statusCode = healthy ? StatusCodes.OK : StatusCodes.SERVICE_UNAVAILABLE;\n\n if (sendHeader) {\n response.setHeader(\"Content-Type\", \"application/json\");\n }\n\n response.end(JSON.stringify(payload, null, 2));\n };\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck } from \"../types\";\n\nexport default <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) =>\n async (_request: Request, response: Response): Promise<void> => {\n const { healthy } = await healthCheck.getReport();\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment\n response.statusCode = healthy ? StatusCodes.NO_CONTENT : StatusCodes.SERVICE_UNAVAILABLE;\n response.end();\n };\n","import type { Checker, HealthCheck as HealthcheckInterface, HealthReport, HealthReportEntry } from \"./types\";\n\nclass Healthcheck implements HealthcheckInterface {\n /**\n * A copy of registered checkers\n */\n private healthCheckers: Record<string, Checker> = {};\n\n public addChecker(service: string, checker: Checker): void {\n // eslint-disable-next-line security/detect-object-injection\n this.healthCheckers[service] = checker;\n }\n\n /**\n * Returns the health check reports. The health checks are performed when\n * this method is invoked.\n */\n public async getReport(): Promise<{ healthy: boolean; report: HealthReport }> {\n const report: HealthReport = {};\n\n // eslint-disable-next-line compat/compat\n await Promise.all(Object.keys(this.healthCheckers).map(async (service) => await this.invokeChecker(service, report)));\n\n /**\n * Finding unhealthy service to know if system is healthy or not\n */\n // eslint-disable-next-line security/detect-object-injection\n const unhealthyService = Object.keys(report).find((service) => !(report[service] as HealthReportEntry).health.healthy);\n\n return { healthy: !unhealthyService, report };\n }\n\n public async isLive(): Promise<boolean> {\n const { healthy } = await this.getReport();\n\n return healthy;\n }\n\n /**\n * Returns an array of registered services names\n */\n public get servicesList(): string[] {\n return Object.keys(this.healthCheckers);\n }\n\n /**\n * Invokes a given checker to collect the report metrics.\n */\n private async invokeChecker(service: string, reportSheet: HealthReport): Promise<boolean> {\n // eslint-disable-next-line security/detect-object-injection\n const checker = this.healthCheckers[service] as Checker;\n\n let report: HealthReportEntry;\n\n try {\n report = await checker();\n\n report.displayName = report.displayName || service;\n } catch (error) {\n report = {\n displayName: service,\n health: { healthy: false, message: (error as Error).message, timestamp: new Date().toISOString() },\n meta: { fatal: true },\n };\n }\n\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n reportSheet[service] = report;\n\n return report.health.healthy;\n }\n}\n\nexport default Healthcheck;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/checks/dns-check.ts","../src/checks/http-check.ts","../src/checks/node-environment-check.ts","../src/checks/ping-check.ts","../src/handler/healthcheck.ts","../src/handler/readyhandler.ts","../src/healthcheck.ts"],"names":["CacheableLookup","DISPLAY_NAME","dnsCheck","host","expectedAddresses","options","family","hints","config","cacheable","meta","error","dns_check_default","deepStrictEqual","httpCheck","response","textBody","http_check_default","nodeEnvironmentCheck","expectedEnvironment","environment","errorMessage","node_environment_check_default","ping","pingCheck","ping_check_default","StatusCodes","healthcheck_default","healthCheck","sendHeader","_","healthy","report","payload","readyhandler_default","_request","Healthcheck","service","checker","reportSheet"],"mappings":"AACA,OAAOA,MAAqB,mBAI5B,IAAMC,EAAe,gBAUfC,EACF,CAACC,EAAcC,EAA8BC,IAC7C,SAAY,CACR,GAAM,CAAE,OAAAC,EAAS,MAAO,MAAAC,EAAO,GAAGC,CAAO,EAAIH,GAAW,CAAC,EAGnDI,EAAY,IAAIT,EAAgBQ,CAAM,EAE5C,GAAI,CAEA,IAAME,EAAoB,MAAMD,EAAU,YAAYN,EAAK,QAAQ,eAAgB,EAAE,EAAG,CACpF,MAAAI,EACA,GAAID,IAAW,MAAQ,CAAE,IAAK,EAAK,EAAI,CAAE,OAAAA,CAAO,CACpD,CAAkB,EAGlB,OAAI,MAAM,QAAQF,CAAiB,GAAK,CAACA,EAAkB,SAASM,EAAK,OAAO,EACrE,CACH,YAAa,GAAGT,CAAY,IAAIE,CAAI,GACpC,OAAQ,CACJ,QAAS,GAET,QAAS,GAAGF,CAAY,IAAIE,CAAI,qBAAqBO,EAAK,OAAO,eAAeN,EAAkB,KAAK,IAAI,CAAC,IAC5G,UAAW,IAAI,KAAK,EAAE,YAAY,CACtC,EACA,KAAM,CAEF,UAAWM,EACX,KAAAP,CACJ,CACJ,EAGG,CACH,YAAa,GAAGF,CAAY,IAAIE,CAAI,GACpC,OAAQ,CACJ,QAAS,GACT,QAAS,GAAGF,CAAY,IAAIE,CAAI,kBAChC,UAAW,IAAI,KAAK,EAAE,YAAY,CACtC,EACA,KAAM,CAEF,UAAWO,EACX,KAAAP,CACJ,CACJ,CACJ,OAASQ,EAAO,CACZ,MAAO,CACH,YAAa,GAAGV,CAAY,IAAIE,CAAI,GACpC,OAAQ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A,IAAW,cAAyB,CAChC,OAAO,OAAO,KAAK,KAAK,cAAc,CAC1C,CAKA,MAAc,cAAcM,EAAiBE,EAA6C,CAEtF,IAAMD,EAAU,KAAK,eAAeD,CAAO,EAEvCL,EAEJ,GAAI,CACAA,EAAS,MAAMM,EAAQ,EAEvBN,EAAO,YAAcA,EAAO,aAAeK,CAC/C,OAAS1B,EAAO,CACZqB,EAAS,CACL,YAAaK,EACb,OAAQ,CAAE,QAAS,GAAO,QAAU1B,EAAgB,QAAS,UAAW,IAAI,KAAK,EAAE,YAAY,CAAE,EACjG,KAAM,CAAE,MAAO,EAAK,CACxB,CACJ,CAGA,OAAA4B,EAAYF,CAAO,EAAIL,EAEhBA,EAAO,OAAO,OACzB,CACJ,EAEOL,EAAQS","sourcesContent":["import type { EntryObject, LookupOptions, Options } from \"cacheable-lookup\";\nimport CacheableLookup from \"cacheable-lookup\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"DNS check for\";\n\ninterface DnsOptions extends Options {\n family?: \"all\" | 4 | 6;\n hints?: number;\n}\n\n/**\n * Register the `dns` checker to ensure that a domain is reachable.\n */\nconst dnsCheck =\n (host: string, expectedAddresses?: string[], options?: DnsOptions): Checker =>\n async () => {\n const { family = \"all\", hints, ...config } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const cacheable = new CacheableLookup(config);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const meta: EntryObject = await cacheable.lookupAsync(host.replace(/^https?:\\/\\//, \"\"), {\n hints,\n ...(family === \"all\" ? { all: true } : { family }),\n } as LookupOptions);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument\n if (Array.isArray(expectedAddresses) && !expectedAddresses.includes(meta.address)) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n message: `${DISPLAY_NAME} ${host} returned address ${meta.address} instead of ${expectedAddresses.join(\", \")}.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} were resolved.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n },\n };\n }\n };\n\nexport default dnsCheck;\n","import { deepStrictEqual } from \"node:assert\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"HTTP check for\";\n\n/**\n * Register the `http` checker to ensure http body and status is correct.\n */\nconst httpCheck =\n (\n host: RequestInfo | URL,\n options?: {\n expected?: { body?: string; status?: number };\n fetchOptions?: RequestInit;\n },\n ): Checker =>\n async () => {\n try {\n // eslint-disable-next-line compat/compat\n const response = await fetch(host, options?.fetchOptions ?? {});\n\n if (options?.expected?.status !== undefined && options.expected.status !== response.status) {\n throw new Error(`${DISPLAY_NAME} ${host as string} returned status ${response.status} instead of ${options.expected.status}`);\n }\n\n if (options?.expected?.body !== undefined) {\n const textBody = await response.text();\n\n try {\n deepStrictEqual(textBody, options.expected.body);\n } catch {\n throw new Error(\n `${DISPLAY_NAME} ${host as string} returned body ${JSON.stringify(textBody)} instead of ${JSON.stringify(options.expected.body)}`,\n );\n }\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host as string} was successful.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n status: response.status,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n },\n };\n }\n };\n\nexport default httpCheck;\n","import type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Node Environment Check\";\n\n/**\n * Register the `env` checker to ensure that `NODE_ENV` environment\n * variable is defined.\n */\nconst nodeEnvironmentCheck =\n (expectedEnvironment?: string): Checker =>\n async () => {\n const environment: string | undefined = process.env.NODE_ENV;\n\n let errorMessage: string | undefined;\n\n if (environment !== undefined && expectedEnvironment !== undefined && environment !== expectedEnvironment) {\n errorMessage = `NODE_ENV environment variable is set to \"${environment}\" instead of \"${expectedEnvironment}\".`;\n } else if (!environment) {\n errorMessage = [\"Missing NODE_ENV environment variable.\", \"It can make some parts of the application misbehave\"].join(\" \");\n }\n\n if (errorMessage !== undefined) {\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: false,\n message: errorMessage,\n timestamp: new Date().toISOString(),\n },\n };\n }\n\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: true,\n timestamp: new Date().toISOString(),\n },\n meta: {\n env: environment,\n },\n };\n };\n\nexport default nodeEnvironmentCheck;\n","import type { extendedPingOptions } from \"pingman\";\nimport ping from \"pingman\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Ping check for\";\n\n/**\n * Register the `ping` checker to ensure that a domain is reachable.\n */\nconst pingCheck =\n (host: string, options?: extendedPingOptions): Checker =>\n async () => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call\n const response = await ping(host.replace(/^https?:\\/\\//, \"\"), options);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (!response.alive) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: `Ping failed for ${host}.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} was successful.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n };\n }\n };\n\nexport default pingCheck;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck, HealthReport } from \"../types\";\n\nexport interface HealthCheckApiPayload {\n appName: string;\n appVersion: string;\n message: string;\n reports: HealthReport;\n status: \"error\" | \"ok\";\n timestamp: string;\n}\n\nexport default (healthCheck: HealthCheck, sendHeader: boolean | undefined = true) =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response): Promise<void> => {\n const { healthy, report } = await healthCheck.getReport();\n\n const payload: HealthCheckApiPayload = {\n appName: process.env.APP_NAME ?? \"unknown\",\n appVersion: process.env.APP_VERSION ?? \"unknown\",\n message: healthy ? \"Health check successful\" : \"Health check failed\",\n reports: report,\n status: healthy ? \"ok\" : \"error\",\n timestamp: new Date().toISOString(),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n response.statusCode = healthy ? StatusCodes.OK : StatusCodes.SERVICE_UNAVAILABLE;\n\n if (sendHeader) {\n response.setHeader(\"Content-Type\", \"application/json\");\n }\n\n response.end(JSON.stringify(payload, null, 2));\n };\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck } from \"../types\";\n\nexport default <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) =>\n async (_request: Request, response: Response): Promise<void> => {\n const { healthy } = await healthCheck.getReport();\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment\n response.statusCode = healthy ? StatusCodes.NO_CONTENT : StatusCodes.SERVICE_UNAVAILABLE;\n response.end();\n };\n","import type { Checker, HealthCheck as HealthcheckInterface, HealthReport, HealthReportEntry } from \"./types\";\n\nclass Healthcheck implements HealthcheckInterface {\n /**\n * A copy of registered checkers\n */\n private healthCheckers: Record<string, Checker> = {};\n\n public addChecker(service: string, checker: Checker): void {\n // eslint-disable-next-line security/detect-object-injection\n this.healthCheckers[service] = checker;\n }\n\n /**\n * Returns the health check reports. The health checks are performed when\n * this method is invoked.\n */\n public async getReport(): Promise<{ healthy: boolean; report: HealthReport }> {\n const report: HealthReport = {};\n\n // eslint-disable-next-line compat/compat\n await Promise.all(Object.keys(this.healthCheckers).map(async (service) => await this.invokeChecker(service, report)));\n\n /**\n * Finding unhealthy service to know if system is healthy or not\n */\n // eslint-disable-next-line security/detect-object-injection\n const unhealthyService = Object.keys(report).find((service) => !(report[service] as HealthReportEntry).health.healthy);\n\n return { healthy: !unhealthyService, report };\n }\n\n public async isLive(): Promise<boolean> {\n const { healthy } = await this.getReport();\n\n return healthy;\n }\n\n /**\n * Returns an array of registered services names\n */\n public get servicesList(): string[] {\n return Object.keys(this.healthCheckers);\n }\n\n /**\n * Invokes a given checker to collect the report metrics.\n */\n private async invokeChecker(service: string, reportSheet: HealthReport): Promise<boolean> {\n // eslint-disable-next-line security/detect-object-injection\n const checker = this.healthCheckers[service] as Checker;\n\n let report: HealthReportEntry;\n\n try {\n report = await checker();\n\n report.displayName = report.displayName || service;\n } catch (error) {\n report = {\n displayName: service,\n health: { healthy: false, message: (error as Error).message, timestamp: new Date().toISOString() },\n meta: { fatal: true },\n };\n }\n\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n reportSheet[service] = report;\n\n return report.health.healthy;\n }\n}\n\nexport default Healthcheck;\n"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/checks/dns-check.ts","../src/checks/http-check.ts","../src/checks/node-environment-check.ts","../src/checks/ping-check.ts","../src/handler/healthcheck.ts","../src/handler/readyhandler.ts","../src/healthcheck.ts"],"names":["CacheableLookup","DISPLAY_NAME","dnsCheck","host","expectedAddresses","options","family","hints","config","cacheable","meta","error","dns_check_default","deepStrictEqual","httpCheck","response","textBody","http_check_default","nodeEnvironmentCheck","expectedEnvironment","environment","errorMessage","node_environment_check_default","ping","pingCheck","ping_check_default","StatusCodes","healthcheck_default","healthCheck","sendHeader","_","healthy","report","payload","readyhandler_default","_request","Healthcheck","service","checker","reportSheet"],"mappings":"AACA,OAAOA,MAAqB,mBAI5B,IAAMC,EAAe,gBAUfC,EACF,CAACC,EAAcC,EAA8BC,IAC7C,SAAY,CACR,GAAM,CAAE,OAAAC,EAAS,MAAO,MAAAC,EAAO,GAAGC,CAAO,EAAIH,GAAW,CAAC,EAGnDI,EAAY,IAAIT,EAAgBQ,CAAM,EAE5C,GAAI,CAEA,IAAME,EAAoB,MAAMD,EAAU,YAAYN,EAAK,QAAQ,eAAgB,EAAE,EAAG,CACpF,MAAAI,EACA,GAAID,IAAW,MAAQ,CAAE,IAAK,EAAK,EAAI,CAAE,OAAAA,CAAO,CACpD,CAAkB,EAGlB,OAAI,MAAM,QAAQF,CAAiB,GAAK,CAACA,EAAkB,SAASM,EAAK,OAAO,EACrE,CACH,YAAa,GAAGT,CAAY,IAAIE,CAAI,GACpC,OAAQ,CACJ,QAAS,GAET,QAAS,GAAGF,CAAY,IAAIE,CAAI,qBAAqBO,EAAK,OAAO,eAAeN,EAAkB,KAAK,IAAI,CAAC,IAC5G,UAAW,IAAI,KAAK,EAAE,YAAY,CACtC,EACA,KAAM,CAEF,UAAWM,EACX,KAAAP,CACJ,CACJ,EAGG,CACH,YAAa,GAAGF,CAAY,IAAIE,CAAI,GACpC,O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AQ7G,CAAE,QAAS,CAFO,OAAO,KAAKA,CAAM,EAAE,KAAMK,GAAY,CAAEL,EAAOK,CAAO,EAAwB,OAAO,OAAO,EAEhF,OAAAL,CAAO,CAChD,CAEA,MAAa,QAA2B,CACpC,GAAM,CAAE,QAAAD,CAAQ,EAAI,MAAM,KAAK,UAAU,EAEzC,OAAOA,CACX,CAKA,IAAW,cAAyB,CAChC,OAAO,OAAO,KAAK,KAAK,cAAc,CAC1C,CAKA,MAAc,cAAcM,EAAiBE,EAA6C,CAEtF,IAAMD,EAAU,KAAK,eAAeD,CAAO,EAEvCL,EAEJ,GAAI,CACAA,EAAS,MAAMM,EAAQ,EAEvBN,EAAO,YAAcA,EAAO,aAAeK,CAC/C,OAAS1B,EAAO,CACZqB,EAAS,CACL,YAAaK,EACb,OAAQ,CAAE,QAAS,GAAO,QAAU1B,EAAgB,QAAS,UAAW,IAAI,KAAK,EAAE,YAAY,CAAE,EACjG,KAAM,CAAE,MAAO,EAAK,CACxB,CACJ,CAGA,OAAA4B,EAAYF,CAAO,EAAIL,EAEhBA,EAAO,OAAO,OACzB,CACJ,EAEOL,EAAQS","sourcesContent":["import type { EntryObject, LookupOptions, Options } from \"cacheable-lookup\";\nimport CacheableLookup from \"cacheable-lookup\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"DNS check for\";\n\ninterface DnsOptions extends Options {\n family?: \"all\" | 4 | 6;\n hints?: number;\n}\n\n/**\n * Register the `dns` checker to ensure that a domain is reachable.\n */\nconst dnsCheck =\n (host: string, expectedAddresses?: string[], options?: DnsOptions): Checker =>\n async () => {\n const { family = \"all\", hints, ...config } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const cacheable = new CacheableLookup(config);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const meta: EntryObject = await cacheable.lookupAsync(host.replace(/^https?:\\/\\//, \"\"), {\n hints,\n ...(family === \"all\" ? { all: true } : { family }),\n } as LookupOptions);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument\n if (Array.isArray(expectedAddresses) && !expectedAddresses.includes(meta.address)) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n message: `${DISPLAY_NAME} ${host} returned address ${meta.address} instead of ${expectedAddresses.join(\", \")}.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} were resolved.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n },\n };\n }\n };\n\nexport default dnsCheck;\n","import { deepStrictEqual } from \"node:assert\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"HTTP check for\";\n\n/**\n * Register the `http` checker to ensure http body and status is correct.\n */\nconst httpCheck =\n (\n host: RequestInfo | URL,\n options?: {\n expected?: { body?: string; status?: number };\n fetchOptions?: RequestInit;\n },\n ): Checker =>\n async () => {\n try {\n // eslint-disable-next-line compat/compat\n const response = await fetch(host, options?.fetchOptions ?? {});\n\n if (options?.expected?.status !== undefined && options.expected.status !== response.status) {\n throw new Error(`${DISPLAY_NAME} ${host as string} returned status ${response.status} instead of ${options.expected.status}`);\n }\n\n if (options?.expected?.body !== undefined) {\n const textBody = await response.text();\n\n try {\n deepStrictEqual(textBody, options.expected.body);\n } catch {\n throw new Error(\n `${DISPLAY_NAME} ${host as string} returned body ${JSON.stringify(textBody)} instead of ${JSON.stringify(options.expected.body)}`,\n );\n }\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host as string} was successful.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n status: response.status,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n },\n };\n }\n };\n\nexport default httpCheck;\n","import type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Node Environment Check\";\n\n/**\n * Register the `env` checker to ensure that `NODE_ENV` environment\n * variable is defined.\n */\nconst nodeEnvironmentCheck =\n (expectedEnvironment?: string): Checker =>\n async () => {\n const environment: string | undefined = process.env[\"NODE_ENV\"];\n\n let errorMessage: string | undefined;\n\n if (environment !== undefined && expectedEnvironment !== undefined && environment !== expectedEnvironment) {\n errorMessage = `NODE_ENV environment variable is set to \"${environment}\" instead of \"${expectedEnvironment}\".`;\n } else if (!environment) {\n errorMessage = [\"Missing NODE_ENV environment variable.\", \"It can make some parts of the application misbehave\"].join(\" \");\n }\n\n if (errorMessage !== undefined) {\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: false,\n message: errorMessage,\n timestamp: new Date().toISOString(),\n },\n };\n }\n\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: true,\n timestamp: new Date().toISOString(),\n },\n meta: {\n env: environment,\n },\n };\n };\n\nexport default nodeEnvironmentCheck;\n","import type { extendedPingOptions } from \"pingman\";\nimport ping from \"pingman\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Ping check for\";\n\n/**\n * Register the `ping` checker to ensure that a domain is reachable.\n */\nconst pingCheck =\n (host: string, options?: extendedPingOptions): Checker =>\n async () => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call\n const response = await ping(host.replace(/^https?:\\/\\//, \"\"), options);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (!response.alive) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: `Ping failed for ${host}.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} was successful.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n };\n }\n };\n\nexport default pingCheck;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck, HealthReport } from \"../types\";\n\nexport interface HealthCheckApiPayload {\n appName: string;\n appVersion: string;\n message: string;\n reports: HealthReport;\n status: \"error\" | \"ok\";\n timestamp: string;\n}\n\nexport default (healthCheck: HealthCheck, sendHeader: boolean | undefined = true) =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response): Promise<void> => {\n const { healthy, report } = await healthCheck.getReport();\n\n const payload: HealthCheckApiPayload = {\n appName: process.env[\"APP_NAME\"] ?? \"unknown\",\n appVersion: process.env[\"APP_VERSION\"] ?? \"unknown\",\n message: healthy ? \"Health check successful\" : \"Health check failed\",\n reports: report,\n status: healthy ? \"ok\" : \"error\",\n timestamp: new Date().toISOString(),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n response.statusCode = healthy ? StatusCodes.OK : StatusCodes.SERVICE_UNAVAILABLE;\n\n if (sendHeader) {\n response.setHeader(\"Content-Type\", \"application/json\");\n }\n\n response.end(JSON.stringify(payload, null, 2));\n };\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck } from \"../types\";\n\nexport default <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) =>\n async (_request: Request, response: Response): Promise<void> => {\n const { healthy } = await healthCheck.getReport();\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment\n response.statusCode = healthy ? StatusCodes.NO_CONTENT : StatusCodes.SERVICE_UNAVAILABLE;\n response.end();\n };\n","import type { Checker, HealthCheck as HealthcheckInterface, HealthReport, HealthReportEntry } from \"./types\";\n\nclass Healthcheck implements HealthcheckInterface {\n /**\n * A copy of registered checkers\n */\n private healthCheckers: Record<string, Checker> = {};\n\n public addChecker(service: string, checker: Checker): void {\n // eslint-disable-next-line security/detect-object-injection\n this.healthCheckers[service] = checker;\n }\n\n /**\n * Returns the health check reports. The health checks are performed when\n * this method is invoked.\n */\n public async getReport(): Promise<{ healthy: boolean; report: HealthReport }> {\n const report: HealthReport = {};\n\n // eslint-disable-next-line compat/compat\n await Promise.all(Object.keys(this.healthCheckers).map(async (service) => await this.invokeChecker(service, report)));\n\n /**\n * Finding unhealthy service to know if system is healthy or not\n */\n // eslint-disable-next-line security/detect-object-injection\n const unhealthyService = Object.keys(report).find((service) => !(report[service] as HealthReportEntry).health.healthy);\n\n return { healthy: !unhealthyService, report };\n }\n\n public async isLive(): Promise<boolean> {\n const { healthy } = await this.getReport();\n\n return healthy;\n }\n\n /**\n * Returns an array of registered services names\n */\n public get servicesList(): string[] {\n return Object.keys(this.healthCheckers);\n }\n\n /**\n * Invokes a given checker to collect the report metrics.\n */\n private async invokeChecker(service: string, reportSheet: HealthReport): Promise<boolean> {\n // eslint-disable-next-line security/detect-object-injection\n const checker = this.healthCheckers[service] as Checker;\n\n let report: HealthReportEntry;\n\n try {\n report = await checker();\n\n report.displayName = report.displayName || service;\n } catch (error) {\n report = {\n displayName: service,\n health: { healthy: false, message: (error as Error).message, timestamp: new Date().toISOString() },\n meta: { fatal: true },\n };\n }\n\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n reportSheet[service] = report;\n\n return report.health.healthy;\n }\n}\n\nexport default Healthcheck;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/checks/dns-check.ts","../src/checks/http-check.ts","../src/checks/node-environment-check.ts","../src/checks/ping-check.ts","../src/handler/healthcheck.ts","../src/handler/readyhandler.ts","../src/healthcheck.ts"],"names":["CacheableLookup","DISPLAY_NAME","dnsCheck","host","expectedAddresses","options","family","hints","config","cacheable","meta","error","dns_check_default","deepStrictEqual","httpCheck","response","textBody","http_check_default","nodeEnvironmentCheck","expectedEnvironment","environment","errorMessage","node_environment_check_default","ping","pingCheck","ping_check_default","StatusCodes","healthcheck_default","healthCheck","sendHeader","_","healthy","report","payload","readyhandler_default","_request","Healthcheck","service","checker","reportSheet"],"mappings":"AACA,OAAOA,MAAqB,mBAI5B,IAAMC,EAAe,gBAUfC,EACF,CAACC,EAAcC,EAA8BC,IAC7C,SAAY,CACR,GAAM,CAAE,OAAAC,EAAS,MAAO,MAAAC,EAAO,GAAGC,CAAO,EAAIH,GAAW,CAAC,EAGnDI,EAAY,IAAIT,EAAgBQ,CAAM,EAE5C,GAAI,CAEA,IAAME,EAAoB,MAAMD,EAAU,YAAYN,EAAK,QAAQ,eAAgB,EAAE,EAAG,CACpF,MAAAI,EACA,GAAID,IAAW,MAAQ,CAAE,IAAK,EAAK,EAAI,CAAE,OAAAA,CAAO,CACpD,CAAkB,EAGlB,OAAI,MAAM,QAAQF,CAAiB,GAAK,CAACA,EAAkB,SAASM,EAAK,OAAO,EACrE,CACH,YAAa,GAAGT,CAAY,IAAIE,CAAI,GACpC,OAAQ,CACJ,QAAS,GAET,QAAS,GAAGF,CAAY,IAAIE,C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AAK,eAAeD,CAAO,EAAIC,CACnC,CAMA,MAAa,WAAiE,CAC1E,IAAMN,EAAuB,CAAC,EAG9B,aAAM,QAAQ,IAAI,OAAO,KAAK,KAAK,cAAc,EAAE,IAAI,MAAOK,GAAY,MAAM,KAAK,cAAcA,EAASL,CAAM,CAAC,CAAC,EAQ7G,CAAE,QAAS,CAFO,OAAO,KAAKA,CAAM,EAAE,KAAMK,GAAY,CAAEL,EAAOK,CAAO,EAAwB,OAAO,OAAO,EAEhF,OAAAL,CAAO,CAChD,CAEA,MAAa,QAA2B,CACpC,GAAM,CAAE,QAAAD,CAAQ,EAAI,MAAM,KAAK,UAAU,EAEzC,OAAOA,CACX,CAKA,IAAW,cAAyB,CAChC,OAAO,OAAO,KAAK,KAAK,cAAc,CAC1C,CAKA,MAAc,cAAcM,EAAiBE,EAA6C,CAEtF,IAAMD,EAAU,KAAK,eAAeD,CAAO,EAEvCL,EAEJ,GAAI,CACAA,EAAS,MAAMM,EAAQ,EAEvBN,EAAO,YAAcA,EAAO,aAAeK,CAC/C,OAAS1B,EAAO,CACZqB,EAAS,CACL,YAAaK,EACb,OAAQ,CAAE,QAAS,GAAO,QAAU1B,EAAgB,QAAS,UAAW,IAAI,KAAK,EAAE,YAAY,CAAE,EACjG,KAAM,CAAE,MAAO,EAAK,CACxB,CACJ,CAGA,OAAA4B,EAAYF,CAAO,EAAIL,EAEhBA,EAAO,OAAO,OACzB,CACJ,EAEOL,EAAQS","sourcesContent":["import type { EntryObject, LookupOptions, Options } from \"cacheable-lookup\";\nimport CacheableLookup from \"cacheable-lookup\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"DNS check for\";\n\ninterface DnsOptions extends Options {\n family?: \"all\" | 4 | 6;\n hints?: number;\n}\n\n/**\n * Register the `dns` checker to ensure that a domain is reachable.\n */\nconst dnsCheck =\n (host: string, expectedAddresses?: string[], options?: DnsOptions): Checker =>\n async () => {\n const { family = \"all\", hints, ...config } = options ?? {};\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const cacheable = new CacheableLookup(config);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment\n const meta: EntryObject = await cacheable.lookupAsync(host.replace(/^https?:\\/\\//, \"\"), {\n hints,\n ...(family === \"all\" ? { all: true } : { family }),\n } as LookupOptions);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument\n if (Array.isArray(expectedAddresses) && !expectedAddresses.includes(meta.address)) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n message: `${DISPLAY_NAME} ${host} returned address ${meta.address} instead of ${expectedAddresses.join(\", \")}.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} were resolved.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n addresses: meta,\n host,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n },\n };\n }\n };\n\nexport default dnsCheck;\n","import { deepStrictEqual } from \"node:assert\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"HTTP check for\";\n\n/**\n * Register the `http` checker to ensure http body and status is correct.\n */\nconst httpCheck =\n (\n host: RequestInfo | URL,\n options?: {\n expected?: { body?: string; status?: number };\n fetchOptions?: RequestInit;\n },\n ): Checker =>\n async () => {\n try {\n // eslint-disable-next-line compat/compat\n const response = await fetch(host, options?.fetchOptions ?? {});\n\n if (options?.expected?.status !== undefined && options.expected.status !== response.status) {\n throw new Error(`${DISPLAY_NAME} ${host as string} returned status ${response.status} instead of ${options.expected.status}`);\n }\n\n if (options?.expected?.body !== undefined) {\n const textBody = await response.text();\n\n try {\n deepStrictEqual(textBody, options.expected.body);\n } catch {\n throw new Error(\n `${DISPLAY_NAME} ${host as string} returned body ${JSON.stringify(textBody)} instead of ${JSON.stringify(options.expected.body)}`,\n );\n }\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host as string} was successful.`,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n status: response.status,\n },\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host as string}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n meta: {\n host,\n method: options?.fetchOptions?.method ?? \"GET\",\n },\n };\n }\n };\n\nexport default httpCheck;\n","import type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Node Environment Check\";\n\n/**\n * Register the `env` checker to ensure that `NODE_ENV` environment\n * variable is defined.\n */\nconst nodeEnvironmentCheck =\n (expectedEnvironment?: string): Checker =>\n async () => {\n const environment: string | undefined = process.env.NODE_ENV;\n\n let errorMessage: string | undefined;\n\n if (environment !== undefined && expectedEnvironment !== undefined && environment !== expectedEnvironment) {\n errorMessage = `NODE_ENV environment variable is set to \"${environment}\" instead of \"${expectedEnvironment}\".`;\n } else if (!environment) {\n errorMessage = [\"Missing NODE_ENV environment variable.\", \"It can make some parts of the application misbehave\"].join(\" \");\n }\n\n if (errorMessage !== undefined) {\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: false,\n message: errorMessage,\n timestamp: new Date().toISOString(),\n },\n };\n }\n\n return {\n displayName: DISPLAY_NAME,\n health: {\n healthy: true,\n timestamp: new Date().toISOString(),\n },\n meta: {\n env: environment,\n },\n };\n };\n\nexport default nodeEnvironmentCheck;\n","import type { extendedPingOptions } from \"pingman\";\nimport ping from \"pingman\";\n\nimport type { Checker } from \"../types\";\n\nconst DISPLAY_NAME = \"Ping check for\";\n\n/**\n * Register the `ping` checker to ensure that a domain is reachable.\n */\nconst pingCheck =\n (host: string, options?: extendedPingOptions): Checker =>\n async () => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call\n const response = await ping(host.replace(/^https?:\\/\\//, \"\"), options);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (!response.alive) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: `Ping failed for ${host}.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n }\n\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: true,\n message: `${DISPLAY_NAME} ${host} was successful.`,\n timestamp: new Date().toISOString(),\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n meta: response,\n };\n } catch (error) {\n return {\n displayName: `${DISPLAY_NAME} ${host}`,\n health: {\n healthy: false,\n message: (error as Error).message,\n timestamp: new Date().toISOString(),\n },\n };\n }\n };\n\nexport default pingCheck;\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck, HealthReport } from \"../types\";\n\nexport interface HealthCheckApiPayload {\n appName: string;\n appVersion: string;\n message: string;\n reports: HealthReport;\n status: \"error\" | \"ok\";\n timestamp: string;\n}\n\nexport default (healthCheck: HealthCheck, sendHeader: boolean | undefined = true) =>\n async <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response): Promise<void> => {\n const { healthy, report } = await healthCheck.getReport();\n\n const payload: HealthCheckApiPayload = {\n appName: process.env.APP_NAME ?? \"unknown\",\n appVersion: process.env.APP_VERSION ?? \"unknown\",\n message: healthy ? \"Health check successful\" : \"Health check failed\",\n reports: report,\n status: healthy ? \"ok\" : \"error\",\n timestamp: new Date().toISOString(),\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n response.statusCode = healthy ? StatusCodes.OK : StatusCodes.SERVICE_UNAVAILABLE;\n\n if (sendHeader) {\n response.setHeader(\"Content-Type\", \"application/json\");\n }\n\n response.end(JSON.stringify(payload, null, 2));\n };\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { StatusCodes } from \"http-status-codes\";\n\nimport type { HealthCheck } from \"../types\";\n\nexport default <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) =>\n async (_request: Request, response: Response): Promise<void> => {\n const { healthy } = await healthCheck.getReport();\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment\n response.statusCode = healthy ? StatusCodes.NO_CONTENT : StatusCodes.SERVICE_UNAVAILABLE;\n response.end();\n };\n","import type { Checker, HealthCheck as HealthcheckInterface, HealthReport, HealthReportEntry } from \"./types\";\n\nclass Healthcheck implements HealthcheckInterface {\n /**\n * A copy of registered checkers\n */\n private healthCheckers: Record<string, Checker> = {};\n\n public addChecker(service: string, checker: Checker): void {\n // eslint-disable-next-line security/detect-object-injection\n this.healthCheckers[service] = checker;\n }\n\n /**\n * Returns the health check reports. The health checks are performed when\n * this method is invoked.\n */\n public async getReport(): Promise<{ healthy: boolean; report: HealthReport }> {\n const report: HealthReport = {};\n\n // eslint-disable-next-line compat/compat\n await Promise.all(Object.keys(this.healthCheckers).map(async (service) => await this.invokeChecker(service, report)));\n\n /**\n * Finding unhealthy service to know if system is healthy or not\n */\n // eslint-disable-next-line security/detect-object-injection\n const unhealthyService = Object.keys(report).find((service) => !(report[service] as HealthReportEntry).health.healthy);\n\n return { healthy: !unhealthyService, report };\n }\n\n public async isLive(): Promise<boolean> {\n const { healthy } = await this.getReport();\n\n return healthy;\n }\n\n /**\n * Returns an array of registered services names\n */\n public get servicesList(): string[] {\n return Object.keys(this.healthCheckers);\n }\n\n /**\n * Invokes a given checker to collect the report metrics.\n */\n private async invokeChecker(service: string, reportSheet: HealthReport): Promise<boolean> {\n // eslint-disable-next-line security/detect-object-injection\n const checker = this.healthCheckers[service] as Checker;\n\n let report: HealthReportEntry;\n\n try {\n report = await checker();\n\n report.displayName = report.displayName || service;\n } catch (error) {\n report = {\n displayName: service,\n health: { healthy: false, message: (error as Error).message, timestamp: new Date().toISOString() },\n meta: { fatal: true },\n };\n }\n\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n reportSheet[service] = report;\n\n return report.health.healthy;\n }\n}\n\nexport default Healthcheck;\n"]}
|
package/package.json
CHANGED
|
@@ -1,141 +1,141 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
"name": "@visulima/health-check",
|
|
3
|
+
"version": "2.0.14",
|
|
4
|
+
"description": "A library built to provide support for defining service health for node services. It allows you to register async health checks for your dependencies and the service itself, provides a health endpoint that exposes their status, and health metrics.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"anolilab",
|
|
7
|
+
"visulima",
|
|
8
|
+
"blitz",
|
|
9
|
+
"blitzjs",
|
|
10
|
+
"nextjs",
|
|
11
|
+
"health",
|
|
12
|
+
"check",
|
|
13
|
+
"checks",
|
|
14
|
+
"dns-check",
|
|
15
|
+
"http-check",
|
|
16
|
+
"ping-check"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://www.visulima.com/docs/package/health-check",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/visulima/visulima.git",
|
|
22
|
+
"directory": "packages/health-check"
|
|
23
|
+
},
|
|
24
|
+
"funding": [
|
|
25
|
+
{
|
|
26
|
+
"type": "github",
|
|
27
|
+
"url": "https://github.com/sponsors/prisis"
|
|
23
28
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
"import": {
|
|
47
|
-
"types": "./dist/index.d.mts",
|
|
48
|
-
"default": "./dist/index.mjs"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"./package.json": "./package.json"
|
|
52
|
-
},
|
|
53
|
-
"main": "dist/index.js",
|
|
54
|
-
"module": "dist/index.mjs",
|
|
55
|
-
"source": "src/index.ts",
|
|
56
|
-
"types": "dist/index.d.ts",
|
|
57
|
-
"files": [
|
|
58
|
-
"dist/**",
|
|
59
|
-
"README.md",
|
|
60
|
-
"CHANGELOG.md",
|
|
61
|
-
"LICENSE.md"
|
|
62
|
-
],
|
|
63
|
-
"scripts": {
|
|
64
|
-
"build": "cross-env NODE_ENV=development tsup",
|
|
65
|
-
"build:prod": "cross-env NODE_ENV=production tsup",
|
|
66
|
-
"clean": "rimraf node_modules dist .eslintcache",
|
|
67
|
-
"dev": "pnpm run build --watch",
|
|
68
|
-
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js",
|
|
69
|
-
"lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js --fix",
|
|
70
|
-
"lint:packagejson": "publint --strict",
|
|
71
|
-
"lint:prettier": "prettier --config=.prettierrc.js --check .",
|
|
72
|
-
"lint:prettier:fix": "prettier --config=.prettierrc.js --write .",
|
|
73
|
-
"lint:types": "tsc --noEmit",
|
|
74
|
-
"test": "vitest run",
|
|
75
|
-
"test:coverage": "vitest run --coverage",
|
|
76
|
-
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
77
|
-
"test:watch": "vitest"
|
|
78
|
-
},
|
|
79
|
-
"dependencies": {
|
|
80
|
-
"cacheable-lookup": "^7.0.0",
|
|
81
|
-
"http-status-codes": "^2.3.0",
|
|
82
|
-
"pingman": "^2.0.0"
|
|
83
|
-
},
|
|
84
|
-
"devDependencies": {
|
|
85
|
-
"@anolilab/eslint-config": "^15.0.3",
|
|
86
|
-
"@anolilab/prettier-config": "^5.0.14",
|
|
87
|
-
"@anolilab/semantic-release-preset": "^8.0.3",
|
|
88
|
-
"@babel/core": "^7.24.3",
|
|
89
|
-
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
90
|
-
"@types/node": "18.18.14",
|
|
91
|
-
"@vitest/coverage-v8": "^1.4.0",
|
|
92
|
-
"@vitest/ui": "^1.4.0",
|
|
93
|
-
"cross-env": "^7.0.3",
|
|
94
|
-
"cross-fetch": "^4.0.0",
|
|
95
|
-
"eslint": "^8.57.0",
|
|
96
|
-
"eslint-plugin-deprecation": "^2.0.0",
|
|
97
|
-
"eslint-plugin-etc": "^2.0.3",
|
|
98
|
-
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
99
|
-
"eslint-plugin-mdx": "^3.1.5",
|
|
100
|
-
"eslint-plugin-vitest": "^0.3.26",
|
|
101
|
-
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
102
|
-
"next": "^13.5.6",
|
|
103
|
-
"node-mocks-http": "^1.14.1",
|
|
104
|
-
"prettier": "^3.2.5",
|
|
105
|
-
"react": "^18.2.0",
|
|
106
|
-
"react-dom": "^18.2.0",
|
|
107
|
-
"rimraf": "^5.0.5",
|
|
108
|
-
"semantic-release": "^23.0.5",
|
|
109
|
-
"sort-package-json": "^2.8.0",
|
|
110
|
-
"tsup": "^8.0.2",
|
|
111
|
-
"typescript": "^5.4.3",
|
|
112
|
-
"vitest": "^1.4.0"
|
|
113
|
-
},
|
|
114
|
-
"optionalDependencies": {
|
|
115
|
-
"next": "^13.5.6"
|
|
116
|
-
},
|
|
117
|
-
"engines": {
|
|
118
|
-
"node": ">=18.* <=21.*"
|
|
119
|
-
},
|
|
120
|
-
"os": [
|
|
121
|
-
"darwin",
|
|
122
|
-
"linux",
|
|
123
|
-
"win32"
|
|
124
|
-
],
|
|
125
|
-
"publishConfig": {
|
|
126
|
-
"access": "public",
|
|
127
|
-
"provenance": true
|
|
29
|
+
{
|
|
30
|
+
"type": "consulting",
|
|
31
|
+
"url": "https://anolilab.com/support"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"author": {
|
|
36
|
+
"name": "Daniel Bannert",
|
|
37
|
+
"email": "d.bannert@anolilab.de"
|
|
38
|
+
},
|
|
39
|
+
"sideEffects": false,
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"default": "./dist/index.js"
|
|
45
|
+
},
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/index.d.mts",
|
|
48
|
+
"default": "./dist/index.mjs"
|
|
49
|
+
}
|
|
128
50
|
},
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
51
|
+
"./package.json": "./package.json"
|
|
52
|
+
},
|
|
53
|
+
"main": "dist/index.js",
|
|
54
|
+
"module": "dist/index.mjs",
|
|
55
|
+
"source": "src/index.ts",
|
|
56
|
+
"types": "dist/index.d.ts",
|
|
57
|
+
"files": [
|
|
58
|
+
"dist/**",
|
|
59
|
+
"README.md",
|
|
60
|
+
"CHANGELOG.md",
|
|
61
|
+
"LICENSE.md"
|
|
62
|
+
],
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"cacheable-lookup": "^7.0.0",
|
|
65
|
+
"http-status-codes": "^2.3.0",
|
|
66
|
+
"pingman": "^2.0.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@anolilab/eslint-config": "^15.0.3",
|
|
70
|
+
"@anolilab/prettier-config": "^5.0.14",
|
|
71
|
+
"@anolilab/semantic-release-pnpm": "^1.1.0",
|
|
72
|
+
"@anolilab/semantic-release-preset": "^8.1.0",
|
|
73
|
+
"@babel/core": "^7.24.6",
|
|
74
|
+
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
75
|
+
"@types/node": "18.18.14",
|
|
76
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
77
|
+
"@vitest/ui": "^1.6.0",
|
|
78
|
+
"cross-env": "^7.0.3",
|
|
79
|
+
"cross-fetch": "^4.0.0",
|
|
80
|
+
"eslint": "^8.57.0",
|
|
81
|
+
"eslint-plugin-deprecation": "^3.0.0",
|
|
82
|
+
"eslint-plugin-etc": "^2.0.3",
|
|
83
|
+
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
84
|
+
"eslint-plugin-mdx": "^3.1.5",
|
|
85
|
+
"eslint-plugin-vitest": "^0.4.1",
|
|
86
|
+
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
87
|
+
"next": "^13.5.6",
|
|
88
|
+
"node-mocks-http": "^1.14.1",
|
|
89
|
+
"prettier": "^3.3.0",
|
|
90
|
+
"react": "^18.3.1",
|
|
91
|
+
"react-dom": "^18.3.1",
|
|
92
|
+
"rimraf": "^5.0.7",
|
|
93
|
+
"semantic-release": "23.1.1",
|
|
94
|
+
"tsup": "^8.1.0",
|
|
95
|
+
"typescript": "^5.4.5",
|
|
96
|
+
"vitest": "^1.6.0"
|
|
97
|
+
},
|
|
98
|
+
"optionalDependencies": {
|
|
99
|
+
"next": "^13.5.6"
|
|
100
|
+
},
|
|
101
|
+
"engines": {
|
|
102
|
+
"node": ">=18.* <=22.*"
|
|
103
|
+
},
|
|
104
|
+
"os": [
|
|
105
|
+
"darwin",
|
|
106
|
+
"linux",
|
|
107
|
+
"win32"
|
|
108
|
+
],
|
|
109
|
+
"publishConfig": {
|
|
110
|
+
"access": "public",
|
|
111
|
+
"provenance": true
|
|
112
|
+
},
|
|
113
|
+
"anolilab": {
|
|
114
|
+
"eslint-config": {
|
|
115
|
+
"plugin": {
|
|
116
|
+
"tsdoc": false
|
|
117
|
+
},
|
|
118
|
+
"warn_on_unsupported_typescript_version": false,
|
|
119
|
+
"info_on_disabling_jsx_react_rule": false,
|
|
120
|
+
"info_on_disabling_prettier_conflict_rule": false,
|
|
121
|
+
"info_on_disabling_jsonc_sort_keys_rule": false,
|
|
122
|
+
"info_on_disabling_etc_no_deprecated": false
|
|
140
123
|
}
|
|
141
|
-
}
|
|
124
|
+
},
|
|
125
|
+
"scripts": {
|
|
126
|
+
"build": "cross-env NODE_ENV=development tsup",
|
|
127
|
+
"build:prod": "cross-env NODE_ENV=production tsup",
|
|
128
|
+
"clean": "rimraf node_modules dist .eslintcache",
|
|
129
|
+
"dev": "pnpm run build --watch",
|
|
130
|
+
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js",
|
|
131
|
+
"lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js --fix",
|
|
132
|
+
"lint:package-json": "publint --strict",
|
|
133
|
+
"lint:prettier": "prettier --config=.prettierrc.js --check .",
|
|
134
|
+
"lint:prettier:fix": "prettier --config=.prettierrc.js --write .",
|
|
135
|
+
"lint:types": "tsc --noEmit",
|
|
136
|
+
"test": "vitest run",
|
|
137
|
+
"test:coverage": "vitest run --coverage",
|
|
138
|
+
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
139
|
+
"test:watch": "vitest"
|
|
140
|
+
}
|
|
141
|
+
}
|