@platformatic/tanstack 3.57.0 → 3.58.1

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
@@ -240,7 +240,7 @@ export interface PlatformaticTanStackConfig {
240
240
  reuseTcpPorts?: boolean;
241
241
  startTimeout?: number;
242
242
  restartOnError?: boolean | number;
243
- exitOnUnhandledErrors?: boolean;
243
+ exitOnUnhandledErrors?: boolean | number;
244
244
  gracefulShutdown?: {
245
245
  runtime: number | string;
246
246
  application: number | string;
@@ -262,6 +262,7 @@ export interface PlatformaticTanStackConfig {
262
262
  bufferPoolSize?: number | string;
263
263
  defaultHighWaterMark?: number | string;
264
264
  };
265
+ healthProbes?: boolean | string;
265
266
  undici?: {
266
267
  agentOptions?: {
267
268
  [k: string]: unknown;
package/lib/capability.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ buildAdditionalServerOptions,
2
3
  cleanBasePath,
3
4
  createServerListener,
4
5
  ensureTrailingSlash,
@@ -7,6 +8,7 @@ import {
7
8
  importFile,
8
9
  resolvePackageViaESM
9
10
  } from '@platformatic/basic'
11
+ import { sanitizeHTTPSOptions } from '@platformatic/foundation'
10
12
  import { ViteCapability } from '@platformatic/vite'
11
13
  import inject from 'light-my-request'
12
14
  import { readFile } from 'node:fs/promises'
@@ -82,10 +84,27 @@ export class TanstackCapability extends ViteCapability {
82
84
  const serverPromise = createServerListener(
83
85
  serverOptions?.port ?? true,
84
86
  serverOptions?.hostname ?? true,
85
- typeof serverOptions?.backlog === 'number' ? { backlog: serverOptions.backlog } : {}
87
+ await buildAdditionalServerOptions(serverOptions)
86
88
  )
87
89
 
88
- await importFile(resolve(outputDirectory, 'server/index.mjs'))
90
+ const httpsOptions = await sanitizeHTTPSOptions(serverOptions?.https)
91
+
92
+ if (!httpsOptions?.cert && !httpsOptions?.key) {
93
+ await this.#importProductionNitro(outputDirectory)
94
+ } else {
95
+ const originalCert = process.env.NITRO_SSL_CERT
96
+ const originalKey = process.env.NITRO_SSL_KEY
97
+
98
+ process.env.NITRO_SSL_CERT = this.#serializeCertificateValue(httpsOptions.cert)
99
+ process.env.NITRO_SSL_KEY = this.#serializeCertificateValue(httpsOptions.key)
100
+
101
+ try {
102
+ await this.#importProductionNitro(outputDirectory)
103
+ } finally {
104
+ this.#restoreEnvironmentVariables('NITRO_SSL_CERT', originalCert)
105
+ this.#restoreEnvironmentVariables('NITRO_SSL_KEY', originalKey)
106
+ }
107
+ }
89
108
 
90
109
  this.#server = await serverPromise
91
110
  this.#dispatcher = this.#server.listeners('request')[0]
@@ -128,4 +147,24 @@ export class TanstackCapability extends ViteCapability {
128
147
  const { statusCode, headers, body, payload, rawPayload } = res
129
148
  return { statusCode, headers, body, payload, rawPayload }
130
149
  }
150
+
151
+ #importProductionNitro (outputDirectory) {
152
+ return importFile(resolve(outputDirectory, 'server/index.mjs'))
153
+ }
154
+
155
+ #serializeCertificateValue (value) {
156
+ if (Array.isArray(value)) {
157
+ return value.map(item => item.toString()).join('\n')
158
+ }
159
+
160
+ return value.toString()
161
+ }
162
+
163
+ #restoreEnvironmentVariables (key, originalValue) {
164
+ if (typeof originalValue === 'undefined') {
165
+ delete process.env[key]
166
+ } else {
167
+ process.env[key] = originalValue
168
+ }
169
+ }
131
170
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/tanstack",
3
- "version": "3.57.0",
3
+ "version": "3.58.1",
4
4
  "description": "Platformatic TanStack Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,10 +16,10 @@
16
16
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
17
  "dependencies": {
18
18
  "semver": "^7.6.3",
19
- "@platformatic/foundation": "3.57.0",
20
- "@platformatic/basic": "3.57.0",
21
- "@platformatic/globals": "3.57.0",
22
- "@platformatic/vite": "3.57.0"
19
+ "@platformatic/basic": "3.58.1",
20
+ "@platformatic/foundation": "3.58.1",
21
+ "@platformatic/globals": "3.58.1",
22
+ "@platformatic/vite": "3.58.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@tanstack/react-router": "^1.139.7",
@@ -39,8 +39,8 @@
39
39
  "vite-plugin-solid": "^2.11.10",
40
40
  "vite-tsconfig-paths": "^5.1.4",
41
41
  "ws": "^8.18.0",
42
- "@platformatic/gateway": "3.57.0",
43
- "@platformatic/service": "3.57.0"
42
+ "@platformatic/service": "3.58.1",
43
+ "@platformatic/gateway": "3.58.1"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/tanstack/3.57.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/tanstack/3.58.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic TanStack Config",
5
5
  "type": "object",
@@ -1183,7 +1183,14 @@
1183
1183
  },
1184
1184
  "exitOnUnhandledErrors": {
1185
1185
  "default": true,
1186
- "type": "boolean"
1186
+ "anyOf": [
1187
+ {
1188
+ "type": "boolean"
1189
+ },
1190
+ {
1191
+ "type": "number"
1192
+ }
1193
+ ]
1187
1194
  },
1188
1195
  "gracefulShutdown": {
1189
1196
  "type": "object",
@@ -1365,6 +1372,17 @@
1365
1372
  },
1366
1373
  "additionalProperties": false
1367
1374
  },
1375
+ "healthProbes": {
1376
+ "anyOf": [
1377
+ {
1378
+ "type": "boolean"
1379
+ },
1380
+ {
1381
+ "type": "string"
1382
+ }
1383
+ ],
1384
+ "default": true
1385
+ },
1368
1386
  "undici": {
1369
1387
  "type": "object",
1370
1388
  "properties": {