@platformatic/basic 2.62.1 → 2.63.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/lib/base.js CHANGED
@@ -41,6 +41,7 @@ export class BaseStackable {
41
41
  this.metricsRegistry = new client.Registry()
42
42
  this.#metricsCollected = false
43
43
  this.customHealthCheck = null
44
+ this.customReadinessCheck = null
44
45
  this.startHttpTimer = null
45
46
  this.endHttpTimer = null
46
47
  this.clientWs = null
@@ -48,7 +49,8 @@ export class BaseStackable {
48
49
  this.stdout = standardStreams?.stdout ?? process.stdout
49
50
  this.stderr = standardStreams?.stderr ?? process.stderr
50
51
 
51
- const pinoOptions = buildPinoOptions(this.configManager.current?.logger, this.serverConfig?.logger, this.serviceId, this.workerId, options, this.root)
52
+ const loggerOptions = deepmerge(this.runtimeConfig?.logger ?? {}, this.configManager.current?.logger ?? {})
53
+ const pinoOptions = buildPinoOptions(loggerOptions, this.serverConfig?.logger, this.serviceId, this.workerId, options, this.root)
52
54
  this.logger = pino(pinoOptions, standardStreams?.stdout)
53
55
 
54
56
  // Setup globals
@@ -66,6 +68,8 @@ export class BaseStackable {
66
68
  invalidateHttpCache: this.#invalidateHttpCache.bind(this),
67
69
  prometheus: { client, registry: this.metricsRegistry },
68
70
  setCustomHealthCheck: this.setCustomHealthCheck.bind(this),
71
+ setCustomReadinessCheck: this.setCustomReadinessCheck.bind(this),
72
+ logger: this.logger
69
73
  })
70
74
  }
71
75
 
@@ -130,6 +134,10 @@ export class BaseStackable {
130
134
  this.customHealthCheck = fn
131
135
  }
132
136
 
137
+ setCustomReadinessCheck (fn) {
138
+ this.customReadinessCheck = fn
139
+ }
140
+
133
141
  async getCustomHealthCheck () {
134
142
  if (!this.customHealthCheck) {
135
143
  return true
@@ -137,6 +145,13 @@ export class BaseStackable {
137
145
  return await this.customHealthCheck()
138
146
  }
139
147
 
148
+ async getCustomReadinessCheck () {
149
+ if (!this.customReadinessCheck) {
150
+ return true
151
+ }
152
+ return await this.customReadinessCheck()
153
+ }
154
+
140
155
  setConnectionString (connectionString) {
141
156
  this.connectionString = connectionString
142
157
  }
@@ -152,7 +167,6 @@ export class BaseStackable {
152
167
 
153
168
  registerGlobals (globals) {
154
169
  globalThis.platformatic = Object.assign(globalThis.platformatic ?? {}, globals)
155
- globalThis.platformatic.logger = this.logger
156
170
  }
157
171
 
158
172
  verifyOutputDirectory (path) {
@@ -1,6 +1,6 @@
1
1
  import { ITC } from '@platformatic/itc'
2
2
  import { client, collectMetrics } from '@platformatic/metrics'
3
- import { disablePinoDirectWrite, ensureFlushedWorkerStdio, ensureLoggableError, features } from '@platformatic/utils'
3
+ import { buildPinoFormatters, buildPinoTimestamp, disablePinoDirectWrite, ensureFlushedWorkerStdio, ensureLoggableError, features } from '@platformatic/utils'
4
4
  import diagnosticChannel, { tracingChannel } from 'node:diagnostics_channel'
5
5
  import { EventEmitter, once } from 'node:events'
6
6
  import { readFile } from 'node:fs/promises'
@@ -100,6 +100,7 @@ export class ChildProcess extends ITC {
100
100
  })
101
101
 
102
102
  this.registerGlobals({
103
+ logger: this.#logger,
103
104
  setOpenapiSchema: this.setOpenapiSchema.bind(this),
104
105
  setGraphqlSchema: this.setGraphqlSchema.bind(this),
105
106
  setConnectionString: this.setConnectionString.bind(this),
@@ -198,10 +199,18 @@ export class ChildProcess extends ITC {
198
199
 
199
200
  // Since this is executed by user code, make sure we only override this in the main thread
200
201
  // The rest will be intercepted by the BaseStackable.
202
+ const loggerOptions = globalThis.platformatic?.config?.logger ?? {}
201
203
  const pinoOptions = {
202
- level: 'info',
204
+ ...loggerOptions,
205
+ level: loggerOptions.level ?? 'info',
203
206
  name: globalThis.platformatic.serviceId
204
207
  }
208
+ if (loggerOptions.formatters) {
209
+ pinoOptions.formatters = buildPinoFormatters(loggerOptions.formatters)
210
+ }
211
+ if (loggerOptions.timestamp) {
212
+ pinoOptions.timestamp = buildPinoTimestamp(loggerOptions.timestamp)
213
+ }
205
214
 
206
215
  if (typeof globalThis.platformatic.workerId !== 'undefined') {
207
216
  pinoOptions.base = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "2.62.1",
3
+ "version": "2.63.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,14 +24,14 @@
24
24
  "split2": "^4.2.0",
25
25
  "undici": "^7.0.0",
26
26
  "ws": "^8.18.0",
27
- "@platformatic/config": "2.62.1",
28
- "@platformatic/itc": "2.62.1",
29
- "@platformatic/metrics": "2.62.1",
30
- "@platformatic/telemetry": "2.62.1",
31
- "@platformatic/utils": "2.62.1"
27
+ "@platformatic/config": "2.63.1",
28
+ "@platformatic/metrics": "2.63.1",
29
+ "@platformatic/itc": "2.63.1",
30
+ "@platformatic/telemetry": "2.63.1",
31
+ "@platformatic/utils": "2.63.1"
32
32
  },
33
33
  "devDependencies": {
34
- "borp": "^0.19.0",
34
+ "borp": "^0.20.0",
35
35
  "eslint": "9",
36
36
  "express": "^4.19.2",
37
37
  "fastify": "^5.0.0",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.62.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.63.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Stackable",
5
5
  "type": "object",