@platformatic/service 0.31.0 → 0.32.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/help/compile.txt +1 -1
- package/lib/load-config.js +8 -4
- package/lib/plugins/metrics.js +4 -8
- package/lib/root-endpoint/index.js +1 -1
- package/lib/root-endpoint/public/index.html +1 -1
- package/package.json +6 -6
- package/test/https.test.js +2 -2
- package/test/lambda.test.js +2 -2
- package/test/load-and-reload-files.test.js +4 -4
- package/test/metrics.test.js +23 -0
- package/test/routes.test.js +1 -1
package/help/compile.txt
CHANGED
|
@@ -10,4 +10,4 @@ plugins in the `outDir` directory.
|
|
|
10
10
|
If not specified, the configuration specified will be loaded from
|
|
11
11
|
`platformatic.service.json`, `platformatic.service.yml`, or `platformatic.service.tml` in the current directory.
|
|
12
12
|
You can find more details about the configuration format at:
|
|
13
|
-
https://
|
|
13
|
+
https://docs.platformatic.dev/docs/reference/service/configuration.
|
package/lib/load-config.js
CHANGED
|
@@ -53,10 +53,14 @@ Error: ${err}
|
|
|
53
53
|
envWhitelist
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
try {
|
|
57
|
+
const parsingResult = await configManager.parse()
|
|
58
|
+
if (!parsingResult) {
|
|
59
|
+
printConfigValidationErrors(configManager)
|
|
60
|
+
process.exit(1)
|
|
61
|
+
}
|
|
62
|
+
} finally {
|
|
63
|
+
configManager.stopWatching()
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
return { configManager, args }
|
package/lib/plugins/metrics.js
CHANGED
|
@@ -12,7 +12,6 @@ const Fastify = require('fastify')
|
|
|
12
12
|
// prometheus. It's an antipattern, so do
|
|
13
13
|
// not use it elsewhere.
|
|
14
14
|
let server = null
|
|
15
|
-
let handler = null
|
|
16
15
|
|
|
17
16
|
module.exports = fp(async function (app, opts) {
|
|
18
17
|
let port = 9090
|
|
@@ -60,7 +59,6 @@ module.exports = fp(async function (app, opts) {
|
|
|
60
59
|
if (server && server.address().port !== port) {
|
|
61
60
|
await new Promise((resolve) => server.close(resolve))
|
|
62
61
|
server = null
|
|
63
|
-
handler = null
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
if (!server) {
|
|
@@ -71,12 +69,10 @@ module.exports = fp(async function (app, opts) {
|
|
|
71
69
|
|
|
72
70
|
const promServer = Fastify({
|
|
73
71
|
name: 'Prometheus server',
|
|
74
|
-
serverFactory: (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
server.on('request', _handler)
|
|
79
|
-
handler = _handler
|
|
72
|
+
serverFactory: (handler) => {
|
|
73
|
+
server.removeAllListeners('request')
|
|
74
|
+
server.removeAllListeners('clientError')
|
|
75
|
+
server.on('request', handler)
|
|
80
76
|
return server
|
|
81
77
|
},
|
|
82
78
|
logger: app.log.child({ name: 'prometheus' })
|
|
@@ -21,7 +21,7 @@ module.exports = async (app, opts) => {
|
|
|
21
21
|
return reply.sendFile('./index.html')
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
return { message: 'Welcome to Platformatic! Please visit https://
|
|
24
|
+
return { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' }
|
|
25
25
|
}
|
|
26
26
|
})
|
|
27
27
|
}
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
<h1 class="text-center"><span>Welcome to</span><br/><span class="text-main-green">Platformatic Service</span></h1>
|
|
203
203
|
<h2 class="text-center">Explore our flexible toolkit for building robust APIs.</h2>
|
|
204
204
|
<div class="button-container">
|
|
205
|
-
<a href="https://
|
|
205
|
+
<a href="https://docs.platformatic.dev" target="_blank" class="button-link">Documentation</a>
|
|
206
206
|
<a id="openapi-link" target="_blank" class="button-link">OpenAPI Documentation</a>
|
|
207
207
|
<a id="graphql-link" target="_blank" class="button-link">GraphiQL</a>
|
|
208
208
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"pino-pretty": "^10.0.0",
|
|
65
65
|
"rfdc": "^1.3.0",
|
|
66
66
|
"ua-parser-js": "^1.0.35",
|
|
67
|
-
"@platformatic/client": "0.
|
|
68
|
-
"@platformatic/config": "0.
|
|
69
|
-
"@platformatic/swagger-ui-theme": "0.
|
|
70
|
-
"@platformatic/types": "0.
|
|
71
|
-
"@platformatic/utils": "0.
|
|
67
|
+
"@platformatic/client": "0.32.0",
|
|
68
|
+
"@platformatic/config": "0.32.0",
|
|
69
|
+
"@platformatic/swagger-ui-theme": "0.32.0",
|
|
70
|
+
"@platformatic/types": "0.32.0",
|
|
71
|
+
"@platformatic/utils": "0.32.0"
|
|
72
72
|
},
|
|
73
73
|
"standard": {
|
|
74
74
|
"ignore": [
|
package/test/https.test.js
CHANGED
|
@@ -52,7 +52,7 @@ test('supports https options', async ({ teardown, equal, same, plan, comment })
|
|
|
52
52
|
let res = await (request(`${app.url}/`))
|
|
53
53
|
equal(res.statusCode, 200)
|
|
54
54
|
let body = await res.body.json()
|
|
55
|
-
same(body, { message: 'Welcome to Platformatic! Please visit https://
|
|
55
|
+
same(body, { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' })
|
|
56
56
|
|
|
57
57
|
await app.restart()
|
|
58
58
|
|
|
@@ -60,5 +60,5 @@ test('supports https options', async ({ teardown, equal, same, plan, comment })
|
|
|
60
60
|
res = await (request(`${app.url}/`))
|
|
61
61
|
equal(res.statusCode, 200)
|
|
62
62
|
body = await res.body.json()
|
|
63
|
-
same(body, { message: 'Welcome to Platformatic! Please visit https://
|
|
63
|
+
same(body, { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' })
|
|
64
64
|
})
|
package/test/lambda.test.js
CHANGED
|
@@ -38,11 +38,11 @@ test('should respond 200 on root endpoint', async ({ teardown, equal, same, ok }
|
|
|
38
38
|
|
|
39
39
|
const ret = await handler(evt)
|
|
40
40
|
|
|
41
|
-
equal(ret.body, JSON.stringify({ message: 'Welcome to Platformatic! Please visit https://
|
|
41
|
+
equal(ret.body, JSON.stringify({ message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' }))
|
|
42
42
|
equal(ret.isBase64Encoded, false)
|
|
43
43
|
ok(ret.headers)
|
|
44
44
|
equal(ret.headers['content-type'], 'application/json; charset=utf-8')
|
|
45
|
-
equal(ret.headers['content-length'], '
|
|
45
|
+
equal(ret.headers['content-length'], '81')
|
|
46
46
|
ok(ret.headers.date)
|
|
47
47
|
equal(ret.headers.connection, 'keep-alive')
|
|
48
48
|
}
|
|
@@ -38,7 +38,7 @@ test('load and reload', async ({ teardown, equal, pass, same }) => {
|
|
|
38
38
|
const res = await request(`${app.url}/`)
|
|
39
39
|
equal(res.statusCode, 200, 'status code')
|
|
40
40
|
const data = await res.body.json()
|
|
41
|
-
same(data, { message: 'Welcome to Platformatic! Please visit https://
|
|
41
|
+
same(data, { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' })
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
await writeFile(file, `
|
|
@@ -52,7 +52,7 @@ test('load and reload', async ({ teardown, equal, pass, same }) => {
|
|
|
52
52
|
const res = await request(`${app.url}/`)
|
|
53
53
|
equal(res.statusCode, 200, 'add status code')
|
|
54
54
|
// The plugin is in Node's module cache, so the new value is not seen.
|
|
55
|
-
same(await res.body.json(), { message: 'Welcome to Platformatic! Please visit https://
|
|
55
|
+
same(await res.body.json(), { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' })
|
|
56
56
|
}
|
|
57
57
|
})
|
|
58
58
|
|
|
@@ -161,7 +161,7 @@ test('load and reload ESM', async ({ teardown, equal, pass, same }) => {
|
|
|
161
161
|
const res = await request(`${app.url}/`)
|
|
162
162
|
equal(res.statusCode, 200, 'status code')
|
|
163
163
|
const data = await res.body.json()
|
|
164
|
-
same(data, { message: 'Welcome to Platformatic! Please visit https://
|
|
164
|
+
same(data, { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' })
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
await writeFile(file, `
|
|
@@ -175,6 +175,6 @@ test('load and reload ESM', async ({ teardown, equal, pass, same }) => {
|
|
|
175
175
|
const res = await request(`${app.url}/`)
|
|
176
176
|
equal(res.statusCode, 200, 'add status code')
|
|
177
177
|
// The plugin is in Node's module cache, so the new value is not seen.
|
|
178
|
-
same(await res.body.json(), { message: 'Welcome to Platformatic! Please visit https://
|
|
178
|
+
same(await res.body.json(), { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' })
|
|
179
179
|
}
|
|
180
180
|
})
|
package/test/metrics.test.js
CHANGED
|
@@ -154,6 +154,29 @@ test('do not error on restart', async ({ teardown, equal, fail, match }) => {
|
|
|
154
154
|
testPrometheusOutput(body)
|
|
155
155
|
})
|
|
156
156
|
|
|
157
|
+
test('restarting 10 times does not leak', async ({ teardown, equal, fail, match }) => {
|
|
158
|
+
process.on('warning', (warning) => {
|
|
159
|
+
fail('warning was raised')
|
|
160
|
+
})
|
|
161
|
+
const app = await buildServer({
|
|
162
|
+
server: {
|
|
163
|
+
hostname: '127.0.0.1',
|
|
164
|
+
port: 0
|
|
165
|
+
},
|
|
166
|
+
metrics: true
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
teardown(async () => {
|
|
170
|
+
await app.close()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
await app.start()
|
|
174
|
+
|
|
175
|
+
for (let i = 0; i < 10; i++) {
|
|
176
|
+
await app.restart()
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
157
180
|
function testPrometheusOutput (output) {
|
|
158
181
|
let metricBlock = []
|
|
159
182
|
const lines = output.split('\n')
|
package/test/routes.test.js
CHANGED
|
@@ -28,7 +28,7 @@ test('should respond 200 on root endpoint', async ({ teardown, equal, same }) =>
|
|
|
28
28
|
const res = await (request(`${app.url}/`))
|
|
29
29
|
equal(res.statusCode, 200)
|
|
30
30
|
const body = await res.body.json()
|
|
31
|
-
same(body, { message: 'Welcome to Platformatic! Please visit https://
|
|
31
|
+
same(body, { message: 'Welcome to Platformatic! Please visit https://docs.platformatic.dev' })
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
{
|