@platformatic/service 0.38.1 → 0.39.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/lib/start.js +5 -2
- package/package.json +7 -7
- package/test/fixtures/request-id.js +9 -0
- package/test/routes.test.js +25 -0
package/lib/start.js
CHANGED
|
@@ -5,7 +5,7 @@ const close = require('close-with-grace')
|
|
|
5
5
|
const { loadConfig, ConfigManager, printConfigValidationErrors, printAndExitLoadConfigError } = require('@platformatic/config')
|
|
6
6
|
const { addLoggerToTheConfig } = require('./utils.js')
|
|
7
7
|
const { restartable } = require('@fastify/restartable')
|
|
8
|
-
|
|
8
|
+
const { randomUUID } = require('crypto')
|
|
9
9
|
async function adjustHttpsKeyAndCert (arg) {
|
|
10
10
|
if (typeof arg === 'string') {
|
|
11
11
|
return arg
|
|
@@ -41,7 +41,10 @@ async function buildServer (options, app) {
|
|
|
41
41
|
|
|
42
42
|
async function createRestartable (fastify) {
|
|
43
43
|
const config = configManager.current
|
|
44
|
-
const root = fastify(
|
|
44
|
+
const root = fastify({
|
|
45
|
+
...config.server,
|
|
46
|
+
genReqId: function (req) { return randomUUID() }
|
|
47
|
+
})
|
|
45
48
|
|
|
46
49
|
root.decorate('platformatic', { configManager, config })
|
|
47
50
|
root.register(app)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"pino-pretty": "^10.0.0",
|
|
66
66
|
"rfdc": "^1.3.0",
|
|
67
67
|
"ua-parser-js": "^1.0.35",
|
|
68
|
-
"@platformatic/client": "0.
|
|
69
|
-
"@platformatic/config": "0.
|
|
70
|
-
"@platformatic/swagger-ui-theme": "0.
|
|
71
|
-
"@platformatic/types": "0.
|
|
72
|
-
"@platformatic/utils": "0.
|
|
73
|
-
"@platformatic/telemetry": "0.
|
|
68
|
+
"@platformatic/client": "0.39.0",
|
|
69
|
+
"@platformatic/config": "0.39.0",
|
|
70
|
+
"@platformatic/swagger-ui-theme": "0.39.0",
|
|
71
|
+
"@platformatic/types": "0.39.0",
|
|
72
|
+
"@platformatic/utils": "0.39.0",
|
|
73
|
+
"@platformatic/telemetry": "0.39.0"
|
|
74
74
|
},
|
|
75
75
|
"standard": {
|
|
76
76
|
"ignore": [
|
package/test/routes.test.js
CHANGED
|
@@ -203,3 +203,28 @@ test('openapi disabled by default', async ({ teardown, equal, same }) => {
|
|
|
203
203
|
await res.body.text()
|
|
204
204
|
}
|
|
205
205
|
})
|
|
206
|
+
|
|
207
|
+
test('request id is a uuid', async ({ teardown, equal, match }) => {
|
|
208
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
|
209
|
+
const app = await buildServer({
|
|
210
|
+
server: {
|
|
211
|
+
hostname: '127.0.0.1',
|
|
212
|
+
port: 0
|
|
213
|
+
},
|
|
214
|
+
plugins: {
|
|
215
|
+
paths: [join(__dirname, 'fixtures', 'request-id.js')]
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
teardown(async () => {
|
|
220
|
+
await app.close()
|
|
221
|
+
})
|
|
222
|
+
await app.start()
|
|
223
|
+
|
|
224
|
+
const res = await request(`${app.url}/request-id`, {
|
|
225
|
+
method: 'GET'
|
|
226
|
+
})
|
|
227
|
+
equal(res.statusCode, 200)
|
|
228
|
+
const json = await res.body.json()
|
|
229
|
+
match(json.request_id, UUID_REGEX)
|
|
230
|
+
})
|