@platformatic/astro 3.33.0-alpha.3 → 3.34.0

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/config.d.ts CHANGED
@@ -231,6 +231,10 @@ export interface PlatformaticAstroConfig {
231
231
  gracefulShutdown?: {
232
232
  runtime: number | string;
233
233
  application: number | string;
234
+ /**
235
+ * Add Connection: close header to HTTP responses during graceful shutdown
236
+ */
237
+ closeConnections?: boolean;
234
238
  };
235
239
  health?: {
236
240
  enabled?: boolean | string;
@@ -394,6 +398,23 @@ export interface PlatformaticAstroConfig {
394
398
  */
395
399
  serviceVersion?: string;
396
400
  };
401
+ /**
402
+ * Custom labels to add to HTTP metrics (http_request_all_duration_seconds). Each label extracts its value from an HTTP request header.
403
+ */
404
+ httpCustomLabels?: {
405
+ /**
406
+ * The label name to use in metrics
407
+ */
408
+ name: string;
409
+ /**
410
+ * The HTTP request header to extract the value from
411
+ */
412
+ header: string;
413
+ /**
414
+ * Default value when header is missing (defaults to "unknown")
415
+ */
416
+ default?: string;
417
+ }[];
397
418
  };
398
419
  telemetry?: {
399
420
  enabled?: boolean | string;
package/lib/capability.js CHANGED
@@ -75,6 +75,23 @@ export class AstroCapability extends BaseCapability {
75
75
  return this.isProduction ? this.#app.close() : this.#app.stop()
76
76
  }
77
77
 
78
+ setClosing () {
79
+ super.setClosing()
80
+
81
+ const closeConnections = this.runtimeConfig?.gracefulShutdown?.closeConnections !== false
82
+ if (!closeConnections) return
83
+
84
+ // In production mode with Fastify, close HTTP/2 sessions
85
+ if (this.isProduction && this.#app?.server?.closeHttp2Sessions) {
86
+ this.#app.server.closeHttp2Sessions()
87
+ }
88
+
89
+ // In development mode, Astro/Vite handles its own server
90
+ if (!this.isProduction && this.#server?.closeHttp2Sessions) {
91
+ this.#server.closeHttp2Sessions()
92
+ }
93
+ }
94
+
78
95
  async build () {
79
96
  const config = this.config
80
97
  const command = config.application.commands.build
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/astro",
3
- "version": "3.33.0-alpha.3",
3
+ "version": "3.34.0",
4
4
  "description": "Platformatic Astro Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -19,8 +19,8 @@
19
19
  "@fastify/static": "^8.0.0",
20
20
  "fastify": "^5.7.0",
21
21
  "semver": "^7.6.3",
22
- "@platformatic/foundation": "3.33.0-alpha.3",
23
- "@platformatic/basic": "3.33.0-alpha.3"
22
+ "@platformatic/basic": "3.34.0",
23
+ "@platformatic/foundation": "3.34.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@astrojs/node": "^9.2.0",
@@ -34,8 +34,8 @@
34
34
  "typescript": "^5.5.4",
35
35
  "vite": "^7.0.0",
36
36
  "ws": "^8.18.0",
37
- "@platformatic/gateway": "3.33.0-alpha.3",
38
- "@platformatic/service": "3.33.0-alpha.3"
37
+ "@platformatic/service": "3.34.0",
38
+ "@platformatic/gateway": "3.34.0"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/astro/3.33.0-alpha.3.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/astro/3.34.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Astro Config",
5
5
  "type": "object",
@@ -1111,6 +1111,11 @@
1111
1111
  }
1112
1112
  ],
1113
1113
  "default": 10000
1114
+ },
1115
+ "closeConnections": {
1116
+ "type": "boolean",
1117
+ "default": true,
1118
+ "description": "Add Connection: close header to HTTP responses during graceful shutdown"
1114
1119
  }
1115
1120
  },
1116
1121
  "default": {},
@@ -1651,6 +1656,32 @@
1651
1656
  "endpoint"
1652
1657
  ],
1653
1658
  "additionalProperties": false
1659
+ },
1660
+ "httpCustomLabels": {
1661
+ "type": "array",
1662
+ "description": "Custom labels to add to HTTP metrics (http_request_all_duration_seconds). Each label extracts its value from an HTTP request header.",
1663
+ "items": {
1664
+ "type": "object",
1665
+ "properties": {
1666
+ "name": {
1667
+ "type": "string",
1668
+ "description": "The label name to use in metrics"
1669
+ },
1670
+ "header": {
1671
+ "type": "string",
1672
+ "description": "The HTTP request header to extract the value from"
1673
+ },
1674
+ "default": {
1675
+ "type": "string",
1676
+ "description": "Default value when header is missing (defaults to \"unknown\")"
1677
+ }
1678
+ },
1679
+ "required": [
1680
+ "name",
1681
+ "header"
1682
+ ],
1683
+ "additionalProperties": false
1684
+ }
1654
1685
  }
1655
1686
  },
1656
1687
  "additionalProperties": false