@platformatic/service 2.0.0-alpha.3 → 2.0.0-alpha.5
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/generator/service-generator.js +1 -1
- package/lib/plugins/metrics.js +1 -1
- package/lib/stackable.js +37 -37
- package/package.json +9 -9
- package/schema.json +2 -2
- package/service.mjs +1 -1
|
@@ -83,7 +83,7 @@ declare module 'fastify' {
|
|
|
83
83
|
}
|
|
84
84
|
`
|
|
85
85
|
this.addFile({ path: '', file: 'global.d.ts', contents: GLOBAL_TYPES_TEMPLATE })
|
|
86
|
-
this.addFile({ path: '', file: 'README.md', contents: await readFile(join(__dirname, 'README.md')) })
|
|
86
|
+
this.addFile({ path: '', file: 'README.md', contents: await readFile(join(__dirname, 'README.md'), 'utf-8') })
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
package/lib/plugins/metrics.js
CHANGED
|
@@ -34,7 +34,7 @@ const metricsPlugin = fp(async function (app, opts = {}) {
|
|
|
34
34
|
enabled: true,
|
|
35
35
|
customLabels: {
|
|
36
36
|
// TODO: check if this is set in prom
|
|
37
|
-
telemetry_id: (req) => req.headers['x-telemetry-id'] ?? 'unknown',
|
|
37
|
+
telemetry_id: (req) => req.headers['x-plt-telemetry-id'] ?? 'unknown',
|
|
38
38
|
},
|
|
39
39
|
overrides: {
|
|
40
40
|
histogram: {
|
package/lib/stackable.js
CHANGED
|
@@ -11,9 +11,16 @@ class ServiceStackable {
|
|
|
11
11
|
this.stackable = options.stackable
|
|
12
12
|
|
|
13
13
|
this.configManager = options.configManager
|
|
14
|
-
this.config = this.configManager.current
|
|
15
14
|
this.context = options.context
|
|
16
15
|
|
|
16
|
+
this.configManager.on('error', (err) => {
|
|
17
|
+
/* c8 ignore next */
|
|
18
|
+
this.stackable.log({
|
|
19
|
+
message: 'error reloading the configuration' + err,
|
|
20
|
+
level: 'error',
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
17
24
|
this.#updateConfig()
|
|
18
25
|
}
|
|
19
26
|
|
|
@@ -142,53 +149,46 @@ class ServiceStackable {
|
|
|
142
149
|
serverConfig,
|
|
143
150
|
hasManagementApi,
|
|
144
151
|
isEntrypoint,
|
|
152
|
+
isProduction,
|
|
145
153
|
} = this.context
|
|
146
154
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
configManager.on('error', (err) => {
|
|
150
|
-
/* c8 ignore next */
|
|
151
|
-
this.stackable.log({ message: 'error reloading the configuration' + err, level: 'error' })
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
configManager.update({
|
|
155
|
-
...configManager.current,
|
|
156
|
-
telemetry: telemetryConfig,
|
|
157
|
-
metrics: metricsConfig,
|
|
158
|
-
})
|
|
155
|
+
const config = this.configManager.current
|
|
159
156
|
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
if (telemetryConfig) {
|
|
158
|
+
config.telemetry = telemetryConfig
|
|
159
|
+
}
|
|
160
|
+
if (metricsConfig) {
|
|
161
|
+
config.metrics = metricsConfig
|
|
162
|
+
}
|
|
163
|
+
if (serverConfig) {
|
|
164
|
+
config.server = serverConfig
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
if (
|
|
168
|
-
(hasManagementApi &&
|
|
169
|
-
configManager.current.metrics
|
|
168
|
+
(hasManagementApi && config.metrics === undefined) || config.metrics
|
|
170
169
|
) {
|
|
171
|
-
const labels =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
labels: { serviceId, ...labels },
|
|
179
|
-
},
|
|
180
|
-
})
|
|
170
|
+
const labels = config.metrics?.labels || {}
|
|
171
|
+
config.metrics = {
|
|
172
|
+
server: 'hide',
|
|
173
|
+
defaultMetrics: { enabled: isEntrypoint },
|
|
174
|
+
...config.metrics,
|
|
175
|
+
labels: { serviceId, ...labels },
|
|
176
|
+
}
|
|
181
177
|
}
|
|
182
178
|
|
|
183
179
|
if (!isEntrypoint) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
server: {
|
|
187
|
-
...(configManager.current.server || {}),
|
|
188
|
-
trustProxy: true,
|
|
189
|
-
},
|
|
190
|
-
})
|
|
180
|
+
config.server = config.server ?? {}
|
|
181
|
+
config.server.trustProxy = true
|
|
191
182
|
}
|
|
183
|
+
|
|
184
|
+
if (isProduction) {
|
|
185
|
+
if (config.plugins) {
|
|
186
|
+
config.plugins.typescript = false
|
|
187
|
+
}
|
|
188
|
+
config.watch = { enabled: false }
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
this.configManager.update(config)
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
#initLogger () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/ws": "^8.5.10",
|
|
52
52
|
"ajv": "^8.12.0",
|
|
53
53
|
"cli-progress": "^3.12.0",
|
|
54
|
-
"close-with-grace": "^
|
|
54
|
+
"close-with-grace": "^2.0.0",
|
|
55
55
|
"code-block-writer": "^13.0.1",
|
|
56
56
|
"colorette": "^2.0.20",
|
|
57
57
|
"commist": "^3.2.0",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"rfdc": "^1.3.1",
|
|
77
77
|
"semgrator": "^0.3.0",
|
|
78
78
|
"undici": "^6.9.0",
|
|
79
|
-
"@platformatic/client": "2.0.0-alpha.
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/ts-compiler": "2.0.0-alpha.
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
79
|
+
"@platformatic/client": "2.0.0-alpha.5",
|
|
80
|
+
"@platformatic/config": "2.0.0-alpha.5",
|
|
81
|
+
"@platformatic/generators": "2.0.0-alpha.5",
|
|
82
|
+
"@platformatic/scalar-theme": "2.0.0-alpha.5",
|
|
83
|
+
"@platformatic/ts-compiler": "2.0.0-alpha.5",
|
|
84
|
+
"@platformatic/telemetry": "2.0.0-alpha.5",
|
|
85
|
+
"@platformatic/utils": "2.0.0-alpha.5"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"test": "pnpm run lint && borp -T --concurrency=1 --timeout=180000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.0.0-alpha.
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.0.0-alpha.5.json",
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"title": "Platformatic Service",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
package/service.mjs
CHANGED
|
@@ -56,7 +56,7 @@ export async function runService (argv) {
|
|
|
56
56
|
|
|
57
57
|
/* c8 ignore next 4 */
|
|
58
58
|
if (args.version) {
|
|
59
|
-
console.log('v' + JSON.parse(await readFile(join(import.meta.url, 'package.json'))).version)
|
|
59
|
+
console.log('v' + JSON.parse(await readFile(join(import.meta.url, 'package.json'), 'utf-8')).version)
|
|
60
60
|
process.exit(0)
|
|
61
61
|
}
|
|
62
62
|
|