@astroscope/health 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -20,8 +20,6 @@ npm install @astroscope/health
20
20
 
21
21
  ### 1. Add both integrations to your Astro config
22
22
 
23
- **Important:** `health()` must come **after** `boot()` in the integrations array.
24
-
25
23
  ```ts
26
24
  // astro.config.ts
27
25
  import { defineConfig } from 'astro/config';
@@ -97,6 +95,7 @@ Host to bind the health server to. Defaults to `127.0.0.1` (localhost only). Set
97
95
 
98
96
  - **Type**: `string`
99
97
  - **Default**: `"127.0.0.1"`
98
+ - **Env**: `HEALTH_HOST`
100
99
 
101
100
  ### `port`
102
101
 
@@ -104,6 +103,7 @@ Port for the health server.
104
103
 
105
104
  - **Type**: `number`
106
105
  - **Default**: `9090`
106
+ - **Env**: `HEALTH_PORT`
107
107
 
108
108
  ### `paths`
109
109
 
package/dist/index.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import {
2
2
  registerHealth
3
- } from "./chunk-SBLQMZG6.js";
3
+ } from "./chunk-VKEMDBBI.js";
4
4
 
5
5
  // src/index.ts
6
- import MagicString from "magic-string";
6
+ import { prepend } from "@astroscope/boot/prepend";
7
7
  import { checks, K8sPaths, SimplePaths } from "health-probes";
8
- var VIRTUAL_MODULE_ID = "virtual:@astroscope/health/config";
9
- var RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
10
8
  function health(options = {}) {
11
9
  const enableDev = options.dev ?? false;
12
10
  const serverOptions = {
@@ -17,48 +15,22 @@ function health(options = {}) {
17
15
  return {
18
16
  name: "@astroscope/health",
19
17
  hooks: {
20
- "astro:config:setup": ({ config, command, updateConfig }) => {
21
- const bootIndex = config.integrations.findIndex((i) => i.name === "@astroscope/boot");
22
- const healthIndex = config.integrations.findIndex((i) => i.name === "@astroscope/health");
23
- if (bootIndex === -1) {
24
- throw new Error(
25
- "@astroscope/health requires @astroscope/boot. Add boot() before health() in your integrations array."
26
- );
18
+ "astro:config:setup": ({ config, updateConfig }) => {
19
+ if (!config.integrations.some((i) => i.name === "@astroscope/boot")) {
20
+ throw new Error("@astroscope/health requires @astroscope/boot. Add boot() to your integrations array.");
27
21
  }
28
- if (healthIndex !== -1 && bootIndex > healthIndex) {
29
- throw new Error(
30
- "@astroscope/health must come after @astroscope/boot. Swap the order in your integrations array."
31
- );
32
- }
33
- const isBuild = command === "build";
22
+ prepend(
23
+ `import { registerHealth as __astroscope_registerHealth } from '@astroscope/health/setup';
24
+ __astroscope_registerHealth(${JSON.stringify(serverOptions)});`
25
+ );
34
26
  updateConfig({
35
27
  vite: {
36
28
  plugins: [
37
29
  {
38
30
  name: "@astroscope/health",
39
- resolveId(id) {
40
- if (id === VIRTUAL_MODULE_ID) return RESOLVED_VIRTUAL_MODULE_ID;
41
- },
42
- load(id) {
43
- if (id === RESOLVED_VIRTUAL_MODULE_ID) {
44
- return `export const config = ${JSON.stringify(serverOptions)};`;
45
- }
46
- },
47
31
  configureServer() {
48
32
  if (!enableDev) return;
49
33
  registerHealth(serverOptions);
50
- },
51
- generateBundle(_, bundle) {
52
- if (!isBuild) return;
53
- const entryChunk = bundle["entry.mjs"];
54
- if (!entryChunk || entryChunk.type !== "chunk") return;
55
- const s = new MagicString(entryChunk.code);
56
- s.prepend(`import '@astroscope/health/setup';
57
- `);
58
- entryChunk.code = s.toString();
59
- if (entryChunk.map) {
60
- entryChunk.map = s.generateMap({ hires: true });
61
- }
62
34
  }
63
35
  }
64
36
  ]
@@ -0,0 +1,5 @@
1
+ import { HealthServerOptions } from 'health-probes';
2
+
3
+ declare function registerHealth(config: HealthServerOptions): void;
4
+
5
+ export { registerHealth };
@@ -0,0 +1,6 @@
1
+ import {
2
+ registerHealth
3
+ } from "./chunk-VKEMDBBI.js";
4
+ export {
5
+ registerHealth
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astroscope/health",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Kubernetes-style health probes integration for Astro",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,8 +11,8 @@
11
11
  "import": "./dist/index.js"
12
12
  },
13
13
  "./setup": {
14
- "types": "./dist/setup.d.ts",
15
- "import": "./dist/setup.js"
14
+ "types": "./dist/register.d.ts",
15
+ "import": "./dist/register.js"
16
16
  }
17
17
  },
18
18
  "files": [
@@ -45,14 +45,13 @@
45
45
  },
46
46
  "homepage": "https://github.com/smnbbrv/astroscope/tree/main/packages/health#readme",
47
47
  "scripts": {
48
- "build": "tsup src/index.ts src/setup.ts --format esm --dts --external virtual:@astroscope/health/config",
48
+ "build": "tsup src/index.ts src/register.ts --format esm --dts",
49
49
  "typecheck": "tsc --noEmit",
50
50
  "lint": "eslint 'src/**/*.ts'",
51
51
  "lint:fix": "eslint 'src/**/*.ts' --fix"
52
52
  },
53
53
  "dependencies": {
54
- "health-probes": "^1.0.0",
55
- "magic-string": "^0.30.21"
54
+ "health-probes": "^1.1.0"
56
55
  },
57
56
  "devDependencies": {
58
57
  "@astroscope/boot": "workspace:*",
@@ -61,7 +60,7 @@
61
60
  "typescript": "^5.9.3"
62
61
  },
63
62
  "peerDependencies": {
64
- "@astroscope/boot": ">=0.3.0",
63
+ "@astroscope/boot": ">=0.3.3",
65
64
  "astro": "^5.0.0"
66
65
  }
67
66
  }
package/dist/setup.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/setup.js DELETED
@@ -1,7 +0,0 @@
1
- import {
2
- registerHealth
3
- } from "./chunk-SBLQMZG6.js";
4
-
5
- // src/setup.ts
6
- import { config } from "virtual:@astroscope/health/config";
7
- registerHealth(config);
File without changes