@platformatic/node 2.69.0 → 2.70.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
@@ -211,7 +211,7 @@ export interface PlatformaticNodeJsStackable {
211
211
  maxELU?: number | string;
212
212
  maxHeapUsed?: number | string;
213
213
  maxHeapTotal?: number | string;
214
- maxYoungGeneration?: number;
214
+ maxYoungGeneration?: number | string;
215
215
  };
216
216
  undici?: {
217
217
  agentOptions?: {
@@ -401,6 +401,7 @@ export interface PlatformaticNodeJsStackable {
401
401
  [k: string]: unknown;
402
402
  };
403
403
  serviceTimeout?: number | string;
404
+ messagingTimeout?: number | string;
404
405
  env?: {
405
406
  [k: string]: string;
406
407
  };
package/index.js CHANGED
@@ -115,32 +115,34 @@ export class NodeStackable extends BaseStackable {
115
115
  // Deal with application
116
116
  const factory = ['build', 'create'].find(f => typeof this.#module[f] === 'function')
117
117
 
118
- if (factory) {
119
- // We have build function, this Stackable will not use HTTP unless it is the entrypoint
120
- serverPromise.cancel()
121
-
122
- this.#app = await this.#module[factory]()
123
- this.#isFastify = isFastify(this.#app)
124
- this.#isKoa = isKoa(this.#app)
118
+ if (this.#module.hasServer !== false) {
119
+ if (factory) {
120
+ // We have build function, this Stackable will not use HTTP unless it is the entrypoint
121
+ serverPromise.cancel()
122
+
123
+ this.#app = await this.#module[factory]()
124
+ this.#isFastify = isFastify(this.#app)
125
+ this.#isKoa = isKoa(this.#app)
126
+
127
+ if (this.#isFastify) {
128
+ await this.#app.ready()
129
+ } else if (this.#isKoa) {
130
+ this.#dispatcher = this.#app.callback()
131
+ } else if (this.#app instanceof Server) {
132
+ this.#server = this.#app
133
+ this.#dispatcher = this.#server.listeners('request')[0]
134
+ }
125
135
 
126
- if (this.#isFastify) {
127
- await this.#app.ready()
128
- } else if (this.#isKoa) {
129
- this.#dispatcher = this.#app.callback()
130
- } else if (this.#app instanceof Server) {
131
- this.#server = this.#app
136
+ if (listen) {
137
+ await this._listen()
138
+ }
139
+ } else {
140
+ // User blackbox function, we wait for it to listen on a port
141
+ this.#server = await serverPromise
132
142
  this.#dispatcher = this.#server.listeners('request')[0]
133
- }
134
143
 
135
- if (listen) {
136
- await this._listen()
144
+ this.url = getServerUrl(this.#server)
137
145
  }
138
- } else {
139
- // User blackbox function, we wait for it to listen on a port
140
- this.#server = await serverPromise
141
- this.#dispatcher = this.#server.listeners('request')[0]
142
-
143
- this.url = getServerUrl(this.#server)
144
146
  }
145
147
 
146
148
  await this._collectMetrics()
@@ -202,18 +204,6 @@ export class NodeStackable extends BaseStackable {
202
204
  this.logger.trace({ injectParams, url: this.url }, 'injecting via request')
203
205
  res = await injectViaRequest(this.url, injectParams, onInject)
204
206
  } else {
205
- if (this.startHttpTimer && this.endHttpTimer) {
206
- this.startHttpTimer({ request: injectParams })
207
-
208
- if (onInject) {
209
- const originalOnInject = onInject
210
- onInject = (err, response) => {
211
- this.endHttpTimer({ request: injectParams, response })
212
- originalOnInject(err, response)
213
- }
214
- }
215
- }
216
-
217
207
  if (this.#isFastify) {
218
208
  this.logger.trace({ injectParams }, 'injecting via fastify')
219
209
  res = await this.#app.inject(injectParams, onInject)
@@ -221,10 +211,6 @@ export class NodeStackable extends BaseStackable {
221
211
  this.logger.trace({ injectParams }, 'injecting via light-my-request')
222
212
  res = await inject(this.#dispatcher ?? this.#app, injectParams, onInject)
223
213
  }
224
-
225
- if (this.endHttpTimer && !onInject) {
226
- this.endHttpTimer({ request: injectParams, response: res })
227
- }
228
214
  }
229
215
 
230
216
  /* c8 ignore next 3 */
@@ -250,7 +236,7 @@ export class NodeStackable extends BaseStackable {
250
236
  url: this.url,
251
237
  prefix: this.basePath ?? this.#basePath,
252
238
  wantsAbsoluteUrls: this._getWantsAbsoluteUrls(),
253
- needsRootRedirect: true
239
+ needsRootTrailingSlash: true
254
240
  },
255
241
  connectionStrings: this.connectionString ? [this.connectionString] : []
256
242
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/node",
3
- "version": "2.69.0",
3
+ "version": "2.70.1",
4
4
  "description": "Platformatic Node.js Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -21,10 +21,10 @@
21
21
  "dependencies": {
22
22
  "json5": "^2.2.3",
23
23
  "light-my-request": "^6.0.0",
24
- "@platformatic/basic": "2.69.0",
25
- "@platformatic/config": "2.69.0",
26
- "@platformatic/generators": "2.69.0",
27
- "@platformatic/utils": "2.69.0"
24
+ "@platformatic/basic": "2.70.1",
25
+ "@platformatic/config": "2.70.1",
26
+ "@platformatic/generators": "2.70.1",
27
+ "@platformatic/utils": "2.70.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "borp": "^0.20.0",
@@ -36,8 +36,8 @@
36
36
  "neostandard": "^0.12.0",
37
37
  "tsx": "^4.19.0",
38
38
  "typescript": "^5.5.4",
39
- "@platformatic/service": "2.69.0",
40
- "@platformatic/composer": "2.69.0"
39
+ "@platformatic/composer": "2.70.1",
40
+ "@platformatic/service": "2.70.1"
41
41
  },
42
42
  "scripts": {
43
43
  "test": "pnpm run lint && borp --concurrency=1 --no-timeout",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/node/2.69.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/node/2.70.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Node.js Stackable",
5
5
  "type": "object",
@@ -724,7 +724,6 @@
724
724
  "default": {},
725
725
  "properties": {
726
726
  "enabled": {
727
- "default": true,
728
727
  "anyOf": [
729
728
  {
730
729
  "type": "boolean"
@@ -732,10 +731,10 @@
732
731
  {
733
732
  "type": "string"
734
733
  }
735
- ]
734
+ ],
735
+ "default": true
736
736
  },
737
737
  "interval": {
738
- "default": 30000,
739
738
  "anyOf": [
740
739
  {
741
740
  "type": "number",
@@ -744,10 +743,10 @@
744
743
  {
745
744
  "type": "string"
746
745
  }
747
- ]
746
+ ],
747
+ "default": 30000
748
748
  },
749
749
  "gracePeriod": {
750
- "default": 30000,
751
750
  "anyOf": [
752
751
  {
753
752
  "type": "number",
@@ -756,10 +755,10 @@
756
755
  {
757
756
  "type": "string"
758
757
  }
759
- ]
758
+ ],
759
+ "default": 30000
760
760
  },
761
761
  "maxUnhealthyChecks": {
762
- "default": 10,
763
762
  "anyOf": [
764
763
  {
765
764
  "type": "number",
@@ -768,10 +767,10 @@
768
767
  {
769
768
  "type": "string"
770
769
  }
771
- ]
770
+ ],
771
+ "default": 10
772
772
  },
773
773
  "maxELU": {
774
- "default": 0.99,
775
774
  "anyOf": [
776
775
  {
777
776
  "type": "number",
@@ -781,10 +780,10 @@
781
780
  {
782
781
  "type": "string"
783
782
  }
784
- ]
783
+ ],
784
+ "default": 0.99
785
785
  },
786
786
  "maxHeapUsed": {
787
- "default": 0.99,
788
787
  "anyOf": [
789
788
  {
790
789
  "type": "number",
@@ -794,10 +793,10 @@
794
793
  {
795
794
  "type": "string"
796
795
  }
797
- ]
796
+ ],
797
+ "default": 0.99
798
798
  },
799
799
  "maxHeapTotal": {
800
- "default": 4294967296,
801
800
  "anyOf": [
802
801
  {
803
802
  "type": "number",
@@ -806,11 +805,19 @@
806
805
  {
807
806
  "type": "string"
808
807
  }
809
- ]
808
+ ],
809
+ "default": 4294967296
810
810
  },
811
811
  "maxYoungGeneration": {
812
- "type": "number",
813
- "minimum": 0
812
+ "anyOf": [
813
+ {
814
+ "type": "number",
815
+ "minimum": 0
816
+ },
817
+ {
818
+ "type": "string"
819
+ }
820
+ ]
814
821
  }
815
822
  },
816
823
  "additionalProperties": false
@@ -1285,6 +1292,18 @@
1285
1292
  ],
1286
1293
  "default": 300000
1287
1294
  },
1295
+ "messagingTimeout": {
1296
+ "anyOf": [
1297
+ {
1298
+ "type": "number",
1299
+ "minimum": 1
1300
+ },
1301
+ {
1302
+ "type": "string"
1303
+ }
1304
+ ],
1305
+ "default": 30000
1306
+ },
1288
1307
  "env": {
1289
1308
  "type": "object",
1290
1309
  "additionalProperties": {