@platformatic/service 0.45.1 → 0.46.2

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.
Files changed (120) hide show
  1. package/index.js +2 -2
  2. package/package.json +6 -6
  3. package/fixtures/hello/no-server-logger.json +0 -13
  4. package/fixtures/hello/platformatic.service.json +0 -18
  5. package/fixtures/hello/plugin.js +0 -7
  6. package/fixtures/hello/warn-log.service.json +0 -18
  7. package/fixtures/hello-client/hello/hello.cjs +0 -21
  8. package/fixtures/hello-client/hello/hello.d.ts +0 -34
  9. package/fixtures/hello-client/hello/hello.openapi.json +0 -22
  10. package/fixtures/hello-client/hello/package.json +0 -5
  11. package/fixtures/hello-client/platformatic.service.json +0 -19
  12. package/fixtures/hello-client/plugin.js +0 -8
  13. package/fixtures/hello-client-ts/hello/hello.cjs +0 -21
  14. package/fixtures/hello-client-ts/hello/hello.d.ts +0 -34
  15. package/fixtures/hello-client-ts/hello/hello.openapi.json +0 -22
  16. package/fixtures/hello-client-ts/hello/package.json +0 -5
  17. package/fixtures/hello-client-ts/platformatic.service.json +0 -21
  18. package/fixtures/hello-client-ts/plugin.ts +0 -8
  19. package/fixtures/hello-client-ts/tsconfig.json +0 -23
  20. package/fixtures/hello-client-ts-without-deps/hello.d.ts +0 -34
  21. package/fixtures/hello-client-ts-without-deps/hello.openapi.json +0 -22
  22. package/fixtures/hello-client-ts-without-deps/platformatic.service.json +0 -23
  23. package/fixtures/hello-client-ts-without-deps/plugin.ts +0 -8
  24. package/fixtures/hello-client-ts-without-deps/tsconfig.json +0 -22
  25. package/fixtures/hello-client-without-deps/hello.d.ts +0 -34
  26. package/fixtures/hello-client-without-deps/hello.openapi.json +0 -22
  27. package/fixtures/hello-client-without-deps/platformatic.service.json +0 -21
  28. package/fixtures/hello-client-without-deps/plugin.js +0 -8
  29. package/fixtures/https/embedded-pem.json +0 -20
  30. package/fixtures/https/https.crt +0 -25
  31. package/fixtures/https/https.key +0 -27
  32. package/fixtures/https/pem-path.json +0 -20
  33. package/fixtures/https/plugin.js +0 -7
  34. package/fixtures/options/platformatic.service.yml +0 -9
  35. package/fixtures/options/plugin.js +0 -7
  36. package/test/autoload.test.js +0 -486
  37. package/test/cli/compile-1.test.mjs +0 -532
  38. package/test/cli/compile-2.test.mjs +0 -310
  39. package/test/cli/gen-schema.test.mjs +0 -44
  40. package/test/cli/gen-types.test.mjs +0 -30
  41. package/test/cli/helper.mjs +0 -67
  42. package/test/cli/start.test.mjs +0 -126
  43. package/test/cli/tap-parallel-not-ok +0 -0
  44. package/test/cli/validations.test.mjs +0 -33
  45. package/test/clients.test.js +0 -87
  46. package/test/config.test.js +0 -316
  47. package/test/cors.test.js +0 -291
  48. package/test/fixtures/bad-typescript-plugin/platformatic.service.json +0 -16
  49. package/test/fixtures/bad-typescript-plugin/plugin.ts +0 -5
  50. package/test/fixtures/bad-typescript-plugin/tsconfig.json +0 -22
  51. package/test/fixtures/custom-port-placeholder.json +0 -10
  52. package/test/fixtures/default-env-var-names.json +0 -7
  53. package/test/fixtures/directories/platformatic.service.json +0 -13
  54. package/test/fixtures/directories/plugins/decorator.js +0 -7
  55. package/test/fixtures/directories/routes/foo/bar.js +0 -11
  56. package/test/fixtures/directories/routes/foo/baz/index.js +0 -7
  57. package/test/fixtures/directories/routes/foo/baz/index2.js +0 -11
  58. package/test/fixtures/directories/routes/oof/auto.hooks.js +0 -5
  59. package/test/fixtures/directories/routes/oof/index.js +0 -7
  60. package/test/fixtures/directories/routes/root.js +0 -7
  61. package/test/fixtures/hello-ts-with-config/global.d.ts +0 -8
  62. package/test/fixtures/hello-ts-with-config/platformatic.service.json +0 -16
  63. package/test/fixtures/hello-ts-with-config/plugin.ts +0 -8
  64. package/test/fixtures/hello-ts-with-config/tsconfig.json +0 -23
  65. package/test/fixtures/hello-world-resolver.js +0 -16
  66. package/test/fixtures/missing-property.config.json +0 -1
  67. package/test/fixtures/nested-directories/modules/catalogue/index.js +0 -11
  68. package/test/fixtures/nested-directories/modules/catalogue/routes/products.js +0 -14
  69. package/test/fixtures/nested-directories/modules/inventory/index.js +0 -33
  70. package/test/fixtures/nested-directories/modules/inventory/routes/product.js +0 -15
  71. package/test/fixtures/nested-directories/package.json +0 -3
  72. package/test/fixtures/nested-directories/platformatic.service.json +0 -23
  73. package/test/fixtures/nested-directories/plugins/decorator.js +0 -3
  74. package/test/fixtures/nested-directories/plugins/handlers.js +0 -17
  75. package/test/fixtures/not-load.js +0 -8
  76. package/test/fixtures/not-load.service.json +0 -13
  77. package/test/fixtures/other-side.js +0 -9
  78. package/test/fixtures/request-id.js +0 -9
  79. package/test/fixtures/root-endpoint-plugin.js +0 -8
  80. package/test/fixtures/throw-resolver.js +0 -16
  81. package/test/fixtures/typescript-autoload/platformatic.service.json +0 -16
  82. package/test/fixtures/typescript-autoload/routes/plugin.ts +0 -5
  83. package/test/fixtures/typescript-autoload/tsconfig.json +0 -22
  84. package/test/fixtures/typescript-compiled/compiled/plugin.js +0 -6
  85. package/test/fixtures/typescript-compiled/platformatic.service.json +0 -18
  86. package/test/fixtures/typescript-plugin/platformatic.service.json +0 -16
  87. package/test/fixtures/typescript-plugin/plugin.ts +0 -5
  88. package/test/fixtures/typescript-plugin/tsconfig.json +0 -22
  89. package/test/fixtures/typescript-plugin-custom-flags/platformatic.service.json +0 -18
  90. package/test/fixtures/typescript-plugin-custom-flags/plugin.ts +0 -5
  91. package/test/fixtures/typescript-plugin-custom-flags/tsconfig.json +0 -22
  92. package/test/fixtures/typescript-plugin-custom-tsconfig/a-config-for-ts.json +0 -22
  93. package/test/fixtures/typescript-plugin-custom-tsconfig/platformatic.service.json +0 -18
  94. package/test/fixtures/typescript-plugin-custom-tsconfig/plugin.ts +0 -5
  95. package/test/fixtures/typescript-plugin-nocompile/platformatic.service.json +0 -16
  96. package/test/fixtures/typescript-plugin-nocompile/plugin.ts +0 -5
  97. package/test/fixtures/typescript-plugin-nocompile/tsconfig.json +0 -22
  98. package/test/fixtures/typescript-plugin-nocompile-enabled/platformatic.service.json +0 -18
  99. package/test/fixtures/typescript-plugin-nocompile-enabled/plugin.ts +0 -5
  100. package/test/fixtures/typescript-plugin-nocompile-enabled/tsconfig.json +0 -22
  101. package/test/fixtures/typescript-plugin-nocompile-string/platformatic.service.json +0 -16
  102. package/test/fixtures/typescript-plugin-nocompile-string/plugin.ts +0 -5
  103. package/test/fixtures/typescript-plugin-nocompile-string/tsconfig.json +0 -22
  104. package/test/fixtures/typescript-plugin-string/platformatic.service.json +0 -16
  105. package/test/fixtures/typescript-plugin-string/plugin.ts +0 -5
  106. package/test/fixtures/typescript-plugin-string/tsconfig.json +0 -22
  107. package/test/fixtures/undici-plugin.js +0 -15
  108. package/test/graphql.test.js +0 -219
  109. package/test/healthcheck.test.js +0 -92
  110. package/test/helper.js +0 -30
  111. package/test/https.test.js +0 -64
  112. package/test/lambda.test.js +0 -103
  113. package/test/load-and-reload-files.test.js +0 -180
  114. package/test/load-plugin.test.js +0 -67
  115. package/test/metrics.test.js +0 -220
  116. package/test/routes.test.js +0 -230
  117. package/test/schema.test.js +0 -12
  118. package/test/tap-parallel-ok +0 -0
  119. package/test/telemetry.test.js +0 -87
  120. package/test/utils.test.js +0 -37
@@ -1,87 +0,0 @@
1
- 'use strict'
2
-
3
- const { buildConfig } = require('./helper')
4
- const { test } = require('tap')
5
- const { buildServer } = require('..')
6
- const { request } = require('undici')
7
- const { join } = require('path')
8
- const os = require('os')
9
- const { writeFile } = require('fs/promises')
10
-
11
- test('should not configure telemetry if not configured', async ({ teardown, equal, pass, same }) => {
12
- const app = await buildServer(buildConfig({
13
- server: {
14
- hostname: '127.0.0.1',
15
- port: 0
16
- }
17
- }))
18
-
19
- teardown(async () => {
20
- await app.close()
21
- })
22
- await app.start()
23
- equal(app.openTelemetry, undefined)
24
- })
25
-
26
- test('should setup telemetry if configured', async ({ teardown, equal, pass, same }) => {
27
- const file = join(os.tmpdir(), `${process.pid}-1.js`)
28
-
29
- await writeFile(file, `
30
- module.exports = async function (app, options) {
31
- app.get('/', () => options.message)
32
- }`)
33
-
34
- const app = await buildServer(buildConfig({
35
- server: {
36
- hostname: '127.0.0.1',
37
- port: 0
38
- },
39
-
40
- telemetry: {
41
- serviceName: 'test-service',
42
- version: '1.0.0',
43
- exporter: {
44
- type: 'memory'
45
- }
46
- },
47
- plugins: {
48
- paths: [{
49
- path: file,
50
- options: {
51
- message: 'hello'
52
- }
53
- }]
54
- }
55
- }))
56
-
57
- teardown(async () => {
58
- await app.close()
59
- })
60
- await app.start()
61
-
62
- const res = await request(`${app.url}/`, {
63
- method: 'GET',
64
- headers: {
65
- 'Content-Type': 'application/json'
66
- },
67
- body: JSON.stringify({
68
- query: `
69
- mutation {
70
- savePage(input: { title: "Hello" }) {
71
- id
72
- title
73
- }
74
- }
75
- `
76
- })
77
- })
78
- equal(res.statusCode, 200, 'savePage status code')
79
- const { exporters } = app.openTelemetry
80
- const finishedSpans = exporters[0].getFinishedSpans()
81
- equal(finishedSpans.length, 1)
82
- const span = finishedSpans[0]
83
- equal(span.name, 'GET /')
84
- equal(span.attributes['http.request.method'], 'GET')
85
- equal(span.attributes['url.path'], '/')
86
- equal(span.attributes['http.response.status_code'], 200)
87
- })
@@ -1,37 +0,0 @@
1
- 'use strict'
2
-
3
- const { test } = require('tap')
4
- const { getJSPluginPath, isFileAccessible } = require('../lib/utils')
5
- const { join, resolve } = require('path')
6
-
7
- test('should get the path of a TS plugin', (t) => {
8
- t.plan(1)
9
-
10
- const result = getJSPluginPath('/something', '/something/plugin.ts', '/something/dist')
11
- const expected = join('/something', 'dist', 'plugin.js')
12
- t.equal(result, expected)
13
- })
14
-
15
- test('should get the path of a JS plugin', (t) => {
16
- t.plan(1)
17
-
18
- const result = getJSPluginPath('/something', '/something/plugin.js', '/something/dist')
19
- t.equal(result, '/something/plugin.js')
20
- })
21
-
22
- test('isFileAccessible with dir', async (t) => {
23
- const dir = resolve(join(__dirname, '..', 'fixtures', 'hello'))
24
- t.equal(await isFileAccessible('platformatic.service.json', dir), true)
25
- })
26
-
27
- test('isFileAccessible no dir', async (t) => {
28
- const file = resolve(join(__dirname, '..', 'fixtures', 'hello', 'platformatic.service.json'))
29
- t.equal(await isFileAccessible(file), true)
30
- })
31
-
32
- test('should return the same plugin folder if it\'s already the compiled one', (t) => {
33
- t.plan(1)
34
-
35
- const result = getJSPluginPath('/something', '/something/dist/plugins', '/something/dist')
36
- t.equal(result, '/something/dist/plugins')
37
- })