@platformatic/service 2.8.0 → 2.8.2-alpha.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/index.js +1 -0
- package/lib/plugins/openapi.js +1 -0
- package/lib/stackable.js +15 -1
- package/package.json +9 -9
- package/schema.json +2 -2
package/index.js
CHANGED
|
@@ -184,6 +184,7 @@ async function buildStackable (options, app = platformaticService, Stackable = S
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
module.exports.configType = 'service'
|
|
187
|
+
module.exports.isPLTService = true
|
|
187
188
|
module.exports.app = platformaticService
|
|
188
189
|
module.exports.schema = schema
|
|
189
190
|
module.exports.buildServer = _buildServer
|
package/lib/plugins/openapi.js
CHANGED
|
@@ -18,6 +18,7 @@ async function setupOpenAPI (app, opts) {
|
|
|
18
18
|
description: 'This is a service built on top of Platformatic',
|
|
19
19
|
version: '1.0.0',
|
|
20
20
|
},
|
|
21
|
+
servers: [{ url: globalThis.platformatic?.runtimeBasePath ?? '/' }],
|
|
21
22
|
}, typeof openapi === 'object' ? openapi : {})
|
|
22
23
|
app.log.trace({ openapi: openapiConfig })
|
|
23
24
|
const swaggerOptions = {
|
package/lib/stackable.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { hostname } = require('node:os')
|
|
4
4
|
const { dirname } = require('node:path')
|
|
5
5
|
const { pathToFileURL } = require('node:url')
|
|
6
|
+
const { workerData } = require('node:worker_threads')
|
|
6
7
|
const { printSchema } = require('graphql')
|
|
7
8
|
const pino = require('pino')
|
|
8
9
|
const { collectMetrics } = require('@platformatic/metrics')
|
|
@@ -11,6 +12,8 @@ const { extractTypeScriptCompileOptionsFromConfig } = require('./compile')
|
|
|
11
12
|
const { compile } = require('@platformatic/ts-compiler')
|
|
12
13
|
const { deepmerge } = require('@platformatic/utils')
|
|
13
14
|
|
|
15
|
+
const kITC = Symbol.for('plt.runtime.itc')
|
|
16
|
+
|
|
14
17
|
class ServiceStackable {
|
|
15
18
|
constructor (options) {
|
|
16
19
|
this.app = null
|
|
@@ -26,6 +29,11 @@ class ServiceStackable {
|
|
|
26
29
|
this.context.worker ??= { count: 1, index: 0 }
|
|
27
30
|
this.workerId = this.context.worker.count > 1 ? this.context.worker.index : undefined
|
|
28
31
|
|
|
32
|
+
this.runtimeConfig = deepmerge(
|
|
33
|
+
this.context.runtimeConfig ?? {},
|
|
34
|
+
workerData?.config ?? {}
|
|
35
|
+
)
|
|
36
|
+
|
|
29
37
|
this.configManager.on('error', err => {
|
|
30
38
|
/* c8 ignore next */
|
|
31
39
|
this.stackable.log({
|
|
@@ -44,7 +52,9 @@ class ServiceStackable {
|
|
|
44
52
|
root: this.context.directory ? pathToFileURL(this.context.directory).toString() : undefined,
|
|
45
53
|
setOpenapiSchema: this.setOpenapiSchema.bind(this),
|
|
46
54
|
setGraphqlSchema: this.setGraphqlSchema.bind(this),
|
|
47
|
-
setBasePath: this.setBasePath.bind(this)
|
|
55
|
+
setBasePath: this.setBasePath.bind(this),
|
|
56
|
+
runtimeBasePath: this.runtimeConfig?.basePath ?? null,
|
|
57
|
+
invalidateHttpCache: this.#invalidateHttpCache.bind(this)
|
|
48
58
|
})
|
|
49
59
|
}
|
|
50
60
|
|
|
@@ -224,6 +234,10 @@ class ServiceStackable {
|
|
|
224
234
|
globalThis.platformatic = Object.assign(globalThis.platformatic ?? {}, globals)
|
|
225
235
|
}
|
|
226
236
|
|
|
237
|
+
async #invalidateHttpCache (opts = {}) {
|
|
238
|
+
await globalThis[kITC].send('invalidateHttpCache', opts)
|
|
239
|
+
}
|
|
240
|
+
|
|
227
241
|
#setHttpMetrics () {
|
|
228
242
|
this.app.register(httpMetrics, {
|
|
229
243
|
registry: this.metricsRegistry,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -76,14 +76,14 @@
|
|
|
76
76
|
"rfdc": "^1.3.1",
|
|
77
77
|
"semgrator": "^0.3.0",
|
|
78
78
|
"undici": "^6.9.0",
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/scalar-theme": "2.8.
|
|
84
|
-
"@platformatic/telemetry": "2.8.
|
|
85
|
-
"@platformatic/ts-compiler": "2.8.
|
|
86
|
-
"@platformatic/utils": "2.8.
|
|
79
|
+
"@platformatic/client": "2.8.2-alpha.1",
|
|
80
|
+
"@platformatic/config": "2.8.2-alpha.1",
|
|
81
|
+
"@platformatic/metrics": "2.8.2-alpha.1",
|
|
82
|
+
"@platformatic/generators": "2.8.2-alpha.1",
|
|
83
|
+
"@platformatic/scalar-theme": "2.8.2-alpha.1",
|
|
84
|
+
"@platformatic/telemetry": "2.8.2-alpha.1",
|
|
85
|
+
"@platformatic/ts-compiler": "2.8.2-alpha.1",
|
|
86
|
+
"@platformatic/utils": "2.8.2-alpha.1"
|
|
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.8.
|
|
3
|
-
"version": "2.8.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.8.2-alpha.1.json",
|
|
3
|
+
"version": "2.8.2-alpha.1",
|
|
4
4
|
"title": "Platformatic Service",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|