@platformatic/node 2.13.0 → 2.15.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
@@ -99,5 +99,6 @@ export interface PlatformaticNodeJsStackable {
99
99
  * This Node.js application requires the Absolute URL from the Composer
100
100
  */
101
101
  absoluteUrl?: boolean;
102
+ dispatchViaHttp?: boolean;
102
103
  };
103
104
  }
package/index.js CHANGED
@@ -50,6 +50,7 @@ export class NodeStackable extends BaseStackable {
50
50
  #dispatcher
51
51
  #isFastify
52
52
  #isKoa
53
+ #useHttpForDispatch
53
54
 
54
55
  constructor (options, root, configManager) {
55
56
  super('nodejs', packageJson.version, options, root, configManager)
@@ -122,6 +123,8 @@ export class NodeStackable extends BaseStackable {
122
123
  } else {
123
124
  // User blackbox function, we wait for it to listen on a port
124
125
  this.#server = await serverPromise
126
+ this.#dispatcher = this.#server.listeners('request')[0]
127
+
125
128
  this.url = getServerUrl(this.#server)
126
129
  }
127
130
 
@@ -177,7 +180,7 @@ export class NodeStackable extends BaseStackable {
177
180
  async inject (injectParams, onInject) {
178
181
  let res
179
182
 
180
- if (this.url) {
183
+ if (this.#useHttpForDispatch) {
181
184
  this.logger.trace({ injectParams, url: this.url }, 'injecting via request')
182
185
  res = await injectViaRequest(this.url, injectParams, onInject)
183
186
  } else {
@@ -234,6 +237,17 @@ export class NodeStackable extends BaseStackable {
234
237
  }
235
238
  }
236
239
 
240
+ async getDispatchTarget () {
241
+ this.#useHttpForDispatch =
242
+ this.childManager || (this.url && this.configManager.current.node?.dispatchViaHttp === true)
243
+
244
+ if (this.#useHttpForDispatch) {
245
+ return this.getUrl()
246
+ }
247
+
248
+ return this.getDispatchFunc()
249
+ }
250
+
237
251
  async _listen () {
238
252
  const serverOptions = this.serverConfig
239
253
 
@@ -373,6 +387,11 @@ export async function buildStackable (opts) {
373
387
  dirname: root
374
388
  })
375
389
  await configManager.parseAndValidate()
390
+ const config = configManager.current
391
+ // We need to update the config with the telemetry so the service name
392
+ // used in telemetry can be retreived using the management API
393
+ config.telemetry = opts.context.telemetryConfig
394
+ configManager.update(config)
376
395
 
377
396
  return new NodeStackable(opts, root, configManager)
378
397
  }
package/lib/schema.js CHANGED
@@ -8,12 +8,16 @@ const node = {
8
8
  type: 'object',
9
9
  properties: {
10
10
  main: {
11
- type: 'string',
11
+ type: 'string'
12
12
  },
13
13
  absoluteUrl: {
14
14
  description: 'This Node.js application requires the Absolute URL from the Composer',
15
15
  type: 'boolean',
16
- default: false,
16
+ default: false
17
+ },
18
+ dispatchViaHttp: {
19
+ type: 'boolean',
20
+ default: false
17
21
  }
18
22
  },
19
23
  default: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/node",
3
- "version": "2.13.0",
3
+ "version": "2.15.0",
4
4
  "description": "Platformatic Node.js Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,9 +16,9 @@
16
16
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
17
  "dependencies": {
18
18
  "light-my-request": "^6.0.0",
19
- "@platformatic/config": "2.13.0",
20
- "@platformatic/utils": "2.13.0",
21
- "@platformatic/basic": "2.13.0"
19
+ "@platformatic/basic": "2.15.0",
20
+ "@platformatic/utils": "2.15.0",
21
+ "@platformatic/config": "2.15.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "borp": "^0.18.0",
@@ -30,8 +30,8 @@
30
30
  "neostandard": "^0.11.1",
31
31
  "tsx": "^4.19.0",
32
32
  "typescript": "^5.5.4",
33
- "@platformatic/composer": "2.13.0",
34
- "@platformatic/service": "2.13.0"
33
+ "@platformatic/composer": "2.15.0",
34
+ "@platformatic/service": "2.15.0"
35
35
  },
36
36
  "scripts": {
37
37
  "test": "npm 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.13.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/node/2.15.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Node.js Stackable",
5
5
  "type": "object",
@@ -307,6 +307,10 @@
307
307
  "description": "This Node.js application requires the Absolute URL from the Composer",
308
308
  "type": "boolean",
309
309
  "default": false
310
+ },
311
+ "dispatchViaHttp": {
312
+ "type": "boolean",
313
+ "default": false
310
314
  }
311
315
  },
312
316
  "default": {},