@platformatic/service 2.22.0 → 2.24.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/index.d.ts +1 -2
- package/lib/plugins/sandbox-wrapper.js +3 -7
- package/lib/stackable.js +22 -12
- package/package.json +10 -10
- package/schema.json +2 -2
package/index.d.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
/// <reference types="@fastify/swagger" />
|
|
3
3
|
import { FastifyInstance, FastifyBaseLogger } from 'fastify'
|
|
4
4
|
import ConfigManager from '@platformatic/config'
|
|
5
|
-
import type { ConfigManagerConfig } from '@platformatic/config'
|
|
6
|
-
import type { Stackable as _Stackable, StackableInterface } from '@platformatic/config'
|
|
5
|
+
import type { Stackable as _Stackable, StackableInterface, ConfigManagerConfig } from '@platformatic/config'
|
|
7
6
|
import { BaseGenerator } from '@platformatic/generators'
|
|
8
7
|
import { PlatformaticService } from './config'
|
|
9
8
|
import type { JSONSchemaType } from 'ajv'
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const fp = require('fastify-plugin')
|
|
4
4
|
const autoload = require('@fastify/autoload')
|
|
5
5
|
const { stat } = require('node:fs').promises
|
|
6
|
-
const { createRequire } = require('
|
|
6
|
+
const { createRequire } = require('@platformatic/utils')
|
|
7
7
|
const { join } = require('node:path')
|
|
8
8
|
const { pathToFileURL } = require('node:url')
|
|
9
9
|
|
|
@@ -36,7 +36,7 @@ module.exports = fp(async function (app, opts) {
|
|
|
36
36
|
forceESM: plugin.forceESM,
|
|
37
37
|
ignoreFilter: plugin.ignoreFilter,
|
|
38
38
|
matchFilter: plugin.matchFilter,
|
|
39
|
-
...patternOptions
|
|
39
|
+
...patternOptions
|
|
40
40
|
})
|
|
41
41
|
} else {
|
|
42
42
|
let loaded = await import(pathToFileURL(plugin.path))
|
|
@@ -68,11 +68,7 @@ function patternOptionsFromPlugin (plugin) {
|
|
|
68
68
|
const config = {}
|
|
69
69
|
|
|
70
70
|
// Expected keys for autoload plugin options that expect regexp patterns
|
|
71
|
-
const patternOptionKeys = [
|
|
72
|
-
'ignorePattern',
|
|
73
|
-
'indexPattern',
|
|
74
|
-
'autoHooksPattern',
|
|
75
|
-
]
|
|
71
|
+
const patternOptionKeys = ['ignorePattern', 'indexPattern', 'autoHooksPattern']
|
|
76
72
|
|
|
77
73
|
for (const key of patternOptionKeys) {
|
|
78
74
|
const pattern = plugin[key]
|
package/lib/stackable.js
CHANGED
|
@@ -6,7 +6,7 @@ const { pathToFileURL } = require('node:url')
|
|
|
6
6
|
const { workerData } = require('node:worker_threads')
|
|
7
7
|
const { printSchema } = require('graphql')
|
|
8
8
|
const pino = require('pino')
|
|
9
|
-
const { collectMetrics } = require('@platformatic/metrics')
|
|
9
|
+
const { client, collectMetrics } = require('@platformatic/metrics')
|
|
10
10
|
const httpMetrics = require('@platformatic/fastify-http-metrics')
|
|
11
11
|
const { extractTypeScriptCompileOptionsFromConfig } = require('./compile')
|
|
12
12
|
const { compile } = require('@platformatic/ts-compiler')
|
|
@@ -19,7 +19,7 @@ class ServiceStackable {
|
|
|
19
19
|
this.app = null
|
|
20
20
|
this._init = options.init
|
|
21
21
|
this.stackable = options.stackable
|
|
22
|
-
this.metricsRegistry =
|
|
22
|
+
this.metricsRegistry = new client.Registry()
|
|
23
23
|
|
|
24
24
|
this.configManager = options.configManager
|
|
25
25
|
this.context = options.context ?? {}
|
|
@@ -49,9 +49,11 @@ class ServiceStackable {
|
|
|
49
49
|
root: this.context.directory ? pathToFileURL(this.context.directory).toString() : undefined,
|
|
50
50
|
setOpenapiSchema: this.setOpenapiSchema.bind(this),
|
|
51
51
|
setGraphqlSchema: this.setGraphqlSchema.bind(this),
|
|
52
|
+
setConnectionString: this.setConnectionString.bind(this),
|
|
52
53
|
setBasePath: this.setBasePath.bind(this),
|
|
53
54
|
runtimeBasePath: this.runtimeConfig?.basePath ?? null,
|
|
54
|
-
invalidateHttpCache: this.#invalidateHttpCache.bind(this)
|
|
55
|
+
invalidateHttpCache: this.#invalidateHttpCache.bind(this),
|
|
56
|
+
prometheus: { client, registry: this.metricsRegistry }
|
|
55
57
|
})
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -136,7 +138,8 @@ class ServiceStackable {
|
|
|
136
138
|
needsRootRedirect: false,
|
|
137
139
|
tcp: !!this.app?.url,
|
|
138
140
|
url: this.app?.url
|
|
139
|
-
}
|
|
141
|
+
},
|
|
142
|
+
connectionStrings: [this.connectionString]
|
|
140
143
|
}
|
|
141
144
|
}
|
|
142
145
|
|
|
@@ -180,19 +183,22 @@ class ServiceStackable {
|
|
|
180
183
|
const metricsConfig = this.context.metricsConfig
|
|
181
184
|
|
|
182
185
|
if (metricsConfig !== false) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
await collectMetrics(
|
|
187
|
+
this.serviceId,
|
|
188
|
+
this.workerId,
|
|
189
|
+
{
|
|
190
|
+
defaultMetrics: true,
|
|
191
|
+
httpMetrics: false,
|
|
192
|
+
...metricsConfig
|
|
193
|
+
},
|
|
194
|
+
this.metricsRegistry
|
|
195
|
+
)
|
|
196
|
+
|
|
189
197
|
this.#setHttpMetrics()
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
async getMetrics ({ format }) {
|
|
194
|
-
if (!this.metricsRegistry) return null
|
|
195
|
-
|
|
196
202
|
return format === 'json' ? await this.metricsRegistry.getMetricsAsJSON() : await this.metricsRegistry.metrics()
|
|
197
203
|
}
|
|
198
204
|
|
|
@@ -227,6 +233,10 @@ class ServiceStackable {
|
|
|
227
233
|
this.graphqlSchema = schema
|
|
228
234
|
}
|
|
229
235
|
|
|
236
|
+
setConnectionString (connectionString) {
|
|
237
|
+
this.connectionString = connectionString
|
|
238
|
+
}
|
|
239
|
+
|
|
230
240
|
setBasePath (basePath) {
|
|
231
241
|
this.basePath = basePath
|
|
232
242
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"borp": "^0.19.0",
|
|
24
24
|
"eslint": "9",
|
|
25
25
|
"json-schema-to-typescript": "^15.0.0",
|
|
26
|
-
"neostandard": "^0.
|
|
26
|
+
"neostandard": "^0.12.0",
|
|
27
27
|
"openapi-types": "^12.1.3",
|
|
28
28
|
"pino-abstract-transport": "^2.0.0",
|
|
29
29
|
"self-cert": "^2.0.0",
|
|
@@ -76,14 +76,14 @@
|
|
|
76
76
|
"rfdc": "^1.3.1",
|
|
77
77
|
"semgrator": "^0.3.0",
|
|
78
78
|
"undici": "^7.0.0",
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/scalar-theme": "2.
|
|
84
|
-
"@platformatic/telemetry": "2.
|
|
85
|
-
"@platformatic/
|
|
86
|
-
"@platformatic/
|
|
79
|
+
"@platformatic/config": "2.24.0",
|
|
80
|
+
"@platformatic/metrics": "2.24.0",
|
|
81
|
+
"@platformatic/generators": "2.24.0",
|
|
82
|
+
"@platformatic/client": "2.24.0",
|
|
83
|
+
"@platformatic/scalar-theme": "2.24.0",
|
|
84
|
+
"@platformatic/telemetry": "2.24.0",
|
|
85
|
+
"@platformatic/ts-compiler": "2.24.0",
|
|
86
|
+
"@platformatic/utils": "2.24.0"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"test": "pnpm run lint && borp -T --concurrency=1 --timeout=300000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.
|
|
3
|
-
"version": "2.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.24.0.json",
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"title": "Platformatic Service",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|