@platformatic/vite 3.33.0 → 3.34.1-alpha.3

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 PlatformaticViteConfig {
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 PlatformaticViteConfig {
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
@@ -79,6 +79,23 @@ export class ViteCapability extends BaseCapability {
79
79
  }
80
80
  }
81
81
 
82
+ setClosing () {
83
+ super.setClosing()
84
+
85
+ const closeConnections = this.runtimeConfig?.gracefulShutdown?.closeConnections !== false
86
+ if (!closeConnections) return
87
+
88
+ // In production mode with Fastify, close HTTP/2 sessions
89
+ if (this.isProduction && this.#app?.server?.closeHttp2Sessions) {
90
+ this.#app.server.closeHttp2Sessions()
91
+ }
92
+
93
+ // In development mode, Vite handles its own server
94
+ if (!this.isProduction && this.#server?.closeHttp2Sessions) {
95
+ this.#server.closeHttp2Sessions()
96
+ }
97
+ }
98
+
82
99
  async build () {
83
100
  const config = this.config
84
101
  const command = config.application.commands.build
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/vite",
3
- "version": "3.33.0",
3
+ "version": "3.34.1-alpha.3",
4
4
  "description": "Platformatic Vite Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,9 +18,9 @@
18
18
  "@fastify/static": "^8.0.0",
19
19
  "fastify": "^5.7.0",
20
20
  "semver": "^7.6.3",
21
- "@platformatic/basic": "3.33.0",
22
- "@platformatic/foundation": "3.33.0",
23
- "@platformatic/node": "3.33.0"
21
+ "@platformatic/basic": "3.34.1-alpha.3",
22
+ "@platformatic/foundation": "3.34.1-alpha.3",
23
+ "@platformatic/node": "3.34.1-alpha.3"
24
24
  },
25
25
  "devDependencies": {
26
26
  "cleaner-spec-reporter": "^0.5.0",
@@ -32,8 +32,8 @@
32
32
  "typescript": "^5.5.4",
33
33
  "vite": "^7.1.4",
34
34
  "ws": "^8.18.0",
35
- "@platformatic/gateway": "3.33.0",
36
- "@platformatic/service": "3.33.0"
35
+ "@platformatic/gateway": "3.34.1-alpha.3",
36
+ "@platformatic/service": "3.34.1-alpha.3"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/vite/3.33.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/vite/3.34.1-alpha.3.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Vite 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