@platformatic/service 0.46.1 → 0.47.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.
Files changed (125) hide show
  1. package/.c8rc +6 -0
  2. package/config.d.ts +0 -1
  3. package/index.d.ts +25 -0
  4. package/index.js +1 -0
  5. package/index.test-d.ts +24 -1
  6. package/lib/schema.js +0 -3
  7. package/package.json +9 -7
  8. package/fixtures/hello/no-server-logger.json +0 -13
  9. package/fixtures/hello/platformatic.service.json +0 -18
  10. package/fixtures/hello/plugin.js +0 -7
  11. package/fixtures/hello/warn-log.service.json +0 -18
  12. package/fixtures/hello-client/hello/hello.cjs +0 -21
  13. package/fixtures/hello-client/hello/hello.d.ts +0 -34
  14. package/fixtures/hello-client/hello/hello.openapi.json +0 -22
  15. package/fixtures/hello-client/hello/package.json +0 -5
  16. package/fixtures/hello-client/platformatic.service.json +0 -19
  17. package/fixtures/hello-client/plugin.js +0 -8
  18. package/fixtures/hello-client-ts/hello/hello.cjs +0 -21
  19. package/fixtures/hello-client-ts/hello/hello.d.ts +0 -34
  20. package/fixtures/hello-client-ts/hello/hello.openapi.json +0 -22
  21. package/fixtures/hello-client-ts/hello/package.json +0 -5
  22. package/fixtures/hello-client-ts/platformatic.service.json +0 -21
  23. package/fixtures/hello-client-ts/plugin.ts +0 -8
  24. package/fixtures/hello-client-ts/tsconfig.json +0 -23
  25. package/fixtures/hello-client-ts-without-deps/hello.d.ts +0 -34
  26. package/fixtures/hello-client-ts-without-deps/hello.openapi.json +0 -22
  27. package/fixtures/hello-client-ts-without-deps/platformatic.service.json +0 -23
  28. package/fixtures/hello-client-ts-without-deps/plugin.ts +0 -8
  29. package/fixtures/hello-client-ts-without-deps/tsconfig.json +0 -22
  30. package/fixtures/hello-client-without-deps/hello.d.ts +0 -34
  31. package/fixtures/hello-client-without-deps/hello.openapi.json +0 -22
  32. package/fixtures/hello-client-without-deps/platformatic.service.json +0 -21
  33. package/fixtures/hello-client-without-deps/plugin.js +0 -8
  34. package/fixtures/https/embedded-pem.json +0 -20
  35. package/fixtures/https/https.crt +0 -25
  36. package/fixtures/https/https.key +0 -27
  37. package/fixtures/https/pem-path.json +0 -20
  38. package/fixtures/https/plugin.js +0 -7
  39. package/fixtures/options/platformatic.service.yml +0 -9
  40. package/fixtures/options/plugin.js +0 -7
  41. package/test/autoload.test.js +0 -486
  42. package/test/cli/compile-1.test.mjs +0 -352
  43. package/test/cli/compile-2.test.mjs +0 -310
  44. package/test/cli/gen-schema.test.mjs +0 -44
  45. package/test/cli/gen-types.test.mjs +0 -30
  46. package/test/cli/helper.mjs +0 -67
  47. package/test/cli/start.test.mjs +0 -126
  48. package/test/cli/tap-parallel-not-ok +0 -0
  49. package/test/cli/validations.test.mjs +0 -33
  50. package/test/clients.test.js +0 -87
  51. package/test/config.test.js +0 -316
  52. package/test/cors.test.js +0 -291
  53. package/test/fixtures/bad-typescript-plugin/platformatic.service.json +0 -16
  54. package/test/fixtures/bad-typescript-plugin/plugin.ts +0 -5
  55. package/test/fixtures/bad-typescript-plugin/tsconfig.json +0 -22
  56. package/test/fixtures/custom-port-placeholder.json +0 -10
  57. package/test/fixtures/default-env-var-names.json +0 -7
  58. package/test/fixtures/directories/platformatic.service.json +0 -13
  59. package/test/fixtures/directories/plugins/decorator.js +0 -7
  60. package/test/fixtures/directories/routes/foo/bar.js +0 -11
  61. package/test/fixtures/directories/routes/foo/baz/index.js +0 -7
  62. package/test/fixtures/directories/routes/foo/baz/index2.js +0 -11
  63. package/test/fixtures/directories/routes/oof/auto.hooks.js +0 -5
  64. package/test/fixtures/directories/routes/oof/index.js +0 -7
  65. package/test/fixtures/directories/routes/root.js +0 -7
  66. package/test/fixtures/hello-ts-with-config/global.d.ts +0 -8
  67. package/test/fixtures/hello-ts-with-config/platformatic.service.json +0 -16
  68. package/test/fixtures/hello-ts-with-config/plugin.ts +0 -8
  69. package/test/fixtures/hello-ts-with-config/tsconfig.json +0 -23
  70. package/test/fixtures/hello-world-resolver.js +0 -16
  71. package/test/fixtures/missing-property.config.json +0 -1
  72. package/test/fixtures/nested-directories/modules/catalogue/index.js +0 -11
  73. package/test/fixtures/nested-directories/modules/catalogue/routes/products.js +0 -14
  74. package/test/fixtures/nested-directories/modules/inventory/index.js +0 -33
  75. package/test/fixtures/nested-directories/modules/inventory/routes/product.js +0 -15
  76. package/test/fixtures/nested-directories/package.json +0 -3
  77. package/test/fixtures/nested-directories/platformatic.service.json +0 -23
  78. package/test/fixtures/nested-directories/plugins/decorator.js +0 -3
  79. package/test/fixtures/nested-directories/plugins/handlers.js +0 -17
  80. package/test/fixtures/not-load.js +0 -8
  81. package/test/fixtures/not-load.service.json +0 -13
  82. package/test/fixtures/other-side.js +0 -9
  83. package/test/fixtures/request-id.js +0 -9
  84. package/test/fixtures/root-endpoint-plugin.js +0 -8
  85. package/test/fixtures/throw-resolver.js +0 -16
  86. package/test/fixtures/typescript-autoload/platformatic.service.json +0 -16
  87. package/test/fixtures/typescript-autoload/routes/plugin.ts +0 -5
  88. package/test/fixtures/typescript-autoload/tsconfig.json +0 -22
  89. package/test/fixtures/typescript-compiled/compiled/plugin.js +0 -6
  90. package/test/fixtures/typescript-compiled/platformatic.service.json +0 -18
  91. package/test/fixtures/typescript-plugin/platformatic.service.json +0 -16
  92. package/test/fixtures/typescript-plugin/plugin.ts +0 -5
  93. package/test/fixtures/typescript-plugin/tsconfig.json +0 -22
  94. package/test/fixtures/typescript-plugin-custom-flags/platformatic.service.json +0 -18
  95. package/test/fixtures/typescript-plugin-custom-flags/plugin.ts +0 -5
  96. package/test/fixtures/typescript-plugin-custom-flags/tsconfig.json +0 -22
  97. package/test/fixtures/typescript-plugin-custom-tsconfig/a-config-for-ts.json +0 -22
  98. package/test/fixtures/typescript-plugin-custom-tsconfig/platformatic.service.json +0 -18
  99. package/test/fixtures/typescript-plugin-custom-tsconfig/plugin.ts +0 -5
  100. package/test/fixtures/typescript-plugin-nocompile/platformatic.service.json +0 -16
  101. package/test/fixtures/typescript-plugin-nocompile/plugin.ts +0 -5
  102. package/test/fixtures/typescript-plugin-nocompile/tsconfig.json +0 -22
  103. package/test/fixtures/typescript-plugin-nocompile-enabled/platformatic.service.json +0 -18
  104. package/test/fixtures/typescript-plugin-nocompile-enabled/plugin.ts +0 -5
  105. package/test/fixtures/typescript-plugin-nocompile-enabled/tsconfig.json +0 -22
  106. package/test/fixtures/typescript-plugin-nocompile-string/platformatic.service.json +0 -16
  107. package/test/fixtures/typescript-plugin-nocompile-string/plugin.ts +0 -5
  108. package/test/fixtures/typescript-plugin-nocompile-string/tsconfig.json +0 -22
  109. package/test/fixtures/typescript-plugin-string/platformatic.service.json +0 -16
  110. package/test/fixtures/typescript-plugin-string/plugin.ts +0 -5
  111. package/test/fixtures/typescript-plugin-string/tsconfig.json +0 -22
  112. package/test/fixtures/undici-plugin.js +0 -15
  113. package/test/graphql.test.js +0 -219
  114. package/test/healthcheck.test.js +0 -92
  115. package/test/helper.js +0 -30
  116. package/test/https.test.js +0 -64
  117. package/test/lambda.test.js +0 -103
  118. package/test/load-and-reload-files.test.js +0 -180
  119. package/test/load-plugin.test.js +0 -67
  120. package/test/metrics.test.js +0 -220
  121. package/test/routes.test.js +0 -230
  122. package/test/schema.test.js +0 -12
  123. package/test/tap-parallel-ok +0 -0
  124. package/test/telemetry.test.js +0 -87
  125. package/test/utils.test.js +0 -37
@@ -1,8 +0,0 @@
1
- 'use default'
2
-
3
- /** @type {import('fastify').FastifyPluginAsync<{ optionA: boolean, optionB: string }>} */
4
- module.exports = async function (app) {
5
- app.get('/', async () => {
6
- return app.hello.get()
7
- })
8
- }
@@ -1,20 +0,0 @@
1
- {
2
- "server": {
3
- "hostname": "127.0.0.1",
4
- "port": 0,
5
- "logger": {
6
- "level": "info"
7
- },
8
- "https": {
9
- "cert": "-----BEGIN CERTIFICATE-----\nMIIERDCCAyygAwIBAgIBATANBgkqhkiG9w0BAQUFADBsMRgwFgYDVQQDEw9iYXNl\nLXZpcnR1YWxib3gxCzAJB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zFjKGRrNOqEMjHph8opS9Va0tMOq37rw08wB+JWbdZ\nlv4PXqECgYEA45vXT69+VSinyVrRJmW7OGp9jX5T1ZYdVfEL2s2YdbzBBZ1rHXis\nEL5A13VhnPTETqiUcp+hskzbfZlmukDv4UIqGF7/ZXaDa1Vdgz6yS+FrbvW+Qy1c\n2L1DpbvKMKq+yklvHMCjJhDC6xuQc+xqPZxMokgUy55Z+q8lA5KRamECgYEAtkv3\n1Q36Ue1TdNNZfOKdYN5DVF2zHgSSrQ3vp3ZtRw2d1RTKoT5HrrNtPEn+1xhT0kwf\nPTZn/86xSd9LDeRTJU46jHyH3Yowh9YbmzxFlqXSnGWY0CEIZ0mcZyiUJ1lI/+tr\nTK/9h0yJmTz23qNX1kX9LuYw1y92wz27rsA2JOcCgYEAxi6jw5ajAbNspT6WbkCW\nTAEtYU5l4Mvcr0A7ekEaRyobR7BR3E9+QvXlr7VdUTUu2O6gk027lWymkS5I7FQu\nioz56k6NQuN2erbRvb2RsdCNowgGqqeM+IuTo3NoEggaKDjYrshtRm/ByMUvekCY\nIR0+/O6WbNVss4JdUEcGpwECgYB1HxXZgqODI5FtC6UBAa/PXr2vZIwCCzoZiUyi\nMQpAjlULY9JUCmmPqqPSClB67ZxdDp87essSpT9ukNHt2PY6j6o6PIAmK/TGMR+H\new/SnDNWXEfz4GU/xyF/fajCJzEpi51ipeejl98H3w1VOWjjuA/Uo/xZJJuPEQiW\nW9PtnQKBgQDFJYAQNUqiQ8/o3r5qrQ1m+WwDcSjJo0K+y53WQWWOLQvyaitpxBIV\n6HN6YOqB7D1jjceQisSoGITZklKv5d2szsUwk4OrIDgVjTnbffUPjs18r4sttARV\ni11eYjenblw76OAc5shwCKCGXhKDcpq/23VxjghFqbJw25Ou3A1iMA==\n-----END RSA PRIVATE KEY-----"
11
- }
12
- },
13
- "plugins": {
14
- "paths": ["./plugin.js"]
15
- },
16
- "service": {
17
- "openapi": true
18
- },
19
- "metrics": false
20
- }
@@ -1,25 +0,0 @@
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6HN6YOqB7D1jjceQisSoGITZklKv5d2szsUwk4OrIDgVjTnbffUPjs18r4sttARV
26
- i11eYjenblw76OAc5shwCKCGXhKDcpq/23VxjghFqbJw25Ou3A1iMA==
27
- -----END RSA PRIVATE KEY-----
@@ -1,20 +0,0 @@
1
- {
2
- "server": {
3
- "hostname": "127.0.0.1",
4
- "port": 0,
5
- "logger": {
6
- "level": "info"
7
- },
8
- "https": {
9
- "cert": { "path": "./https.crt" },
10
- "key": [{ "path": "./https.key" }]
11
- }
12
- },
13
- "plugins": {
14
- "paths": ["./plugin.js"]
15
- },
16
- "service": {
17
- "openapi": true
18
- },
19
- "metrics": false
20
- }
@@ -1,7 +0,0 @@
1
- 'use default'
2
-
3
- module.exports = async function (app) {
4
- app.get('/', async () => {
5
- return { hello: 'world' }
6
- })
7
- }
@@ -1,9 +0,0 @@
1
- server:
2
- hostname: "127.0.0.1"
3
- port: 0
4
- plugins:
5
- paths:
6
- - path: "./plugin.js"
7
- options:
8
- something: 'else'
9
- metrics: false
@@ -1,7 +0,0 @@
1
- 'use default'
2
-
3
- module.exports = async function (app, opts) {
4
- app.get('/', async () => {
5
- return opts
6
- })
7
- }
@@ -1,486 +0,0 @@
1
- 'use strict'
2
-
3
- require('./helper')
4
- const { test } = require('tap')
5
- const { buildServer } = require('..')
6
- const { request } = require('undici')
7
- const { join } = require('path')
8
-
9
- test('autoload & filesystem based routing / watch disabled', async ({ teardown, equal }) => {
10
- const config = {
11
- server: {
12
- hostname: '127.0.0.1',
13
- port: 0
14
- },
15
- plugins: {
16
- paths: [join(__dirname, 'fixtures', 'directories', 'routes')]
17
- },
18
- watch: false,
19
- metrics: false
20
- }
21
-
22
- const app = await buildServer(config)
23
- teardown(async () => {
24
- await app.close()
25
- })
26
- await app.start()
27
-
28
- {
29
- const res = await request(`${app.url}/`)
30
- equal(res.statusCode, 200, 'status code')
31
- const body = await res.body.json()
32
- equal(body.hello, 'from root', 'body')
33
- }
34
-
35
- {
36
- const res = await request(`${app.url}/foo/bar`)
37
- equal(res.statusCode, 200, 'status code')
38
- const body = await res.body.json()
39
- equal(body.hello, 'from bar', 'body')
40
- }
41
-
42
- {
43
- const res = await request(`${app.url}/foo/baz`)
44
- equal(res.statusCode, 200, 'status code')
45
- const body = await res.body.json()
46
- equal(body.hello, 'from baz', 'body')
47
- }
48
- })
49
-
50
- test('multiple files / watch false', async ({ teardown, equal }) => {
51
- const config = {
52
- server: {
53
- hostname: '127.0.0.1',
54
- port: 0
55
- },
56
- plugins: {
57
- paths: [{
58
- path: join(__dirname, 'fixtures', 'directories', 'plugins')
59
- }, {
60
- path: join(__dirname, 'fixtures', 'directories', 'routes')
61
- }]
62
- },
63
- watch: false,
64
- metrics: false
65
- }
66
-
67
- const app = await buildServer(config)
68
- teardown(async () => {
69
- await app.close()
70
- })
71
- await app.start()
72
-
73
- {
74
- const res = await request(`${app.url}/`)
75
- equal(res.statusCode, 200, 'status code')
76
- const body = await res.body.json()
77
- equal(body.hello, 'from root', 'body')
78
- }
79
-
80
- {
81
- const res = await request(`${app.url}/foo/bar`)
82
- equal(res.statusCode, 200, 'status code')
83
- const body = await res.body.json()
84
- equal(body.hello, 'from bar', 'body')
85
- }
86
-
87
- {
88
- const res = await request(`${app.url}/foo/baz`)
89
- equal(res.statusCode, 200, 'status code')
90
- const body = await res.body.json()
91
- equal(body.hello, 'from baz', 'body')
92
- }
93
-
94
- {
95
- const res = await request(`${app.url}/foo/with-decorator`)
96
- equal(res.statusCode, 200, 'status code')
97
- const body = await res.body.json()
98
- equal(body.hello, 'bar', 'body')
99
- }
100
- })
101
-
102
- test('autoload & filesystem based routing / watch disabled / no object', async ({ teardown, equal }) => {
103
- const config = {
104
- server: {
105
- hostname: '127.0.0.1',
106
- port: 0
107
- },
108
- plugins: {
109
- paths: [join(__dirname, 'fixtures', 'directories', 'routes')]
110
- },
111
- watch: false,
112
- metrics: false
113
- }
114
-
115
- const app = await buildServer(config)
116
- teardown(async () => {
117
- await app.close()
118
- })
119
- await app.start()
120
-
121
- {
122
- const res = await request(`${app.url}/`)
123
- equal(res.statusCode, 200, 'status code')
124
- const body = await res.body.json()
125
- equal(body.hello, 'from root', 'body')
126
- }
127
-
128
- {
129
- const res = await request(`${app.url}/foo/bar`)
130
- equal(res.statusCode, 200, 'status code')
131
- const body = await res.body.json()
132
- equal(body.hello, 'from bar', 'body')
133
- }
134
-
135
- {
136
- const res = await request(`${app.url}/foo/baz`)
137
- equal(res.statusCode, 200, 'status code')
138
- const body = await res.body.json()
139
- equal(body.hello, 'from baz', 'body')
140
- }
141
- })
142
-
143
- test('multiple files / watch false / no object', async ({ teardown, equal }) => {
144
- const config = {
145
- server: {
146
- hostname: '127.0.0.1',
147
- port: 0
148
- },
149
- plugins: {
150
- paths: [
151
- join(__dirname, 'fixtures', 'directories', 'plugins'),
152
- join(__dirname, 'fixtures', 'directories', 'routes')
153
- ]
154
- },
155
- watch: false,
156
- metrics: false
157
- }
158
-
159
- const app = await buildServer(config)
160
- teardown(async () => {
161
- await app.close()
162
- })
163
- await app.start()
164
-
165
- {
166
- const res = await request(`${app.url}/`)
167
- equal(res.statusCode, 200, 'status code')
168
- const body = await res.body.json()
169
- equal(body.hello, 'from root', 'body')
170
- }
171
-
172
- {
173
- const res = await request(`${app.url}/foo/bar`)
174
- equal(res.statusCode, 200, 'status code')
175
- const body = await res.body.json()
176
- equal(body.hello, 'from bar', 'body')
177
- }
178
-
179
- {
180
- const res = await request(`${app.url}/foo/baz`)
181
- equal(res.statusCode, 200, 'status code')
182
- const body = await res.body.json()
183
- equal(body.hello, 'from baz', 'body')
184
- }
185
-
186
- {
187
- const res = await request(`${app.url}/foo/with-decorator`)
188
- equal(res.statusCode, 200, 'status code')
189
- const body = await res.body.json()
190
- equal(body.hello, 'bar', 'body')
191
- }
192
- })
193
-
194
- test('nested directories', async ({ teardown, equal, same }) => {
195
- const config = {
196
- server: {
197
- hostname: '127.0.0.1',
198
- port: 0,
199
- // Windows CI is slow
200
- pluginTimeout: 60 * 1000
201
- },
202
- service: {
203
- openapi: true
204
- },
205
- plugins: {
206
- paths: [{
207
- path: join(__dirname, 'fixtures', 'nested-directories', 'plugins'),
208
- encapsulate: false
209
- }, {
210
- path: join(__dirname, 'fixtures', 'nested-directories', 'modules'),
211
- encapsulate: false,
212
- maxDepth: 1
213
- }]
214
- }
215
- }
216
-
217
- const app = await buildServer(config)
218
- teardown(async () => {
219
- await app.close()
220
- })
221
- await app.start()
222
-
223
- {
224
- const res = await request(`${app.url}/inventory/product/42`)
225
- equal(res.statusCode, 200, 'status code')
226
- const body = await res.body.json()
227
- same(body, { sku: 42, inStore: 2 }, 'body')
228
- }
229
-
230
- {
231
- const res = await request(`${app.url}/catalogue/products`)
232
- equal(res.statusCode, 200, 'status code')
233
- const body = await res.body.json()
234
- same(body, [{ sku: 42, name: 'foo', inStore: 2 }, { sku: 43, name: 'bar', inStore: 0 }], 'body')
235
- }
236
-
237
- {
238
- const res = await request(`${app.url}/foo/baz`)
239
- equal(res.statusCode, 404, 'status code')
240
- const body = await res.body.text()
241
- equal(body, 'I\'m sorry, I couldn\'t find what you were looking for.')
242
- }
243
-
244
- {
245
- const res = await request(`${app.url}/catalogue/error`)
246
- equal(res.statusCode, 500, 'status code')
247
- const body = await res.body.text()
248
- equal(body, 'I\'m sorry, there was an error processing your request.')
249
- }
250
- })
251
-
252
- test('disable encapsulation for a single file', async ({ teardown, equal, same }) => {
253
- const config = {
254
- server: {
255
- hostname: '127.0.0.1',
256
- port: 0,
257
- // Windows CI is slow
258
- pluginTimeout: 60 * 1000
259
- },
260
- service: {
261
- openapi: true
262
- },
263
- plugins: {
264
- paths: [{
265
- path: join(__dirname, 'fixtures', 'nested-directories', 'plugins', 'decorator.js'),
266
- encapsulate: false
267
- }, {
268
- path: join(__dirname, 'fixtures', 'nested-directories', 'plugins', 'handlers.js'),
269
- encapsulate: false
270
- }, {
271
- path: join(__dirname, 'fixtures', 'nested-directories', 'modules'),
272
- encapsulate: false,
273
- maxDepth: 1
274
- }]
275
- }
276
- }
277
-
278
- const app = await buildServer(config)
279
- teardown(async () => {
280
- await app.close()
281
- })
282
- await app.start()
283
-
284
- {
285
- const res = await request(`${app.url}/foo/baz`)
286
- equal(res.statusCode, 404, 'status code')
287
- const body = await res.body.text()
288
- equal(body, 'I\'m sorry, I couldn\'t find what you were looking for.')
289
- }
290
-
291
- {
292
- const res = await request(`${app.url}/foo`)
293
- equal(res.statusCode, 200, 'status code')
294
- const body = await res.body.text()
295
- equal(body, 'bar')
296
- }
297
- })
298
-
299
- test('disable encapsulation for a single file / different order', async ({ teardown, equal, same }) => {
300
- const config = {
301
- server: {
302
- hostname: '127.0.0.1',
303
- port: 0,
304
- // Windows CI is slow
305
- pluginTimeout: 60 * 1000
306
- },
307
- service: {
308
- openapi: true
309
- },
310
- plugins: {
311
- paths: [{
312
- path: join(__dirname, 'fixtures', 'nested-directories', 'modules'),
313
- encapsulate: false,
314
- maxDepth: 1
315
- }, {
316
- path: join(__dirname, 'fixtures', 'nested-directories', 'plugins', 'decorator.js'),
317
- encapsulate: false
318
- }, {
319
- path: join(__dirname, 'fixtures', 'nested-directories', 'plugins', 'handlers.js'),
320
- encapsulate: false
321
- }]
322
- }
323
- }
324
-
325
- const app = await buildServer(config)
326
- teardown(async () => {
327
- await app.close()
328
- })
329
- await app.start()
330
-
331
- {
332
- const res = await request(`${app.url}/foo/baz`)
333
- equal(res.statusCode, 404, 'status code')
334
- const body = await res.body.text()
335
- equal(body, 'I\'m sorry, I couldn\'t find what you were looking for.')
336
- }
337
-
338
- {
339
- const res = await request(`${app.url}/foo`)
340
- equal(res.statusCode, 200, 'status code')
341
- const body = await res.body.text()
342
- equal(body, 'bar')
343
- }
344
- })
345
-
346
- test('autoload with ignorePattern, indexPattern and autoHooksPattern options', async ({ teardown, equal }) => {
347
- const config = {
348
- server: {
349
- hostname: '127.0.0.1',
350
- port: 0
351
- },
352
- plugins: {
353
- paths: [
354
- {
355
- path: join(__dirname, 'fixtures', 'directories', 'routes'),
356
-
357
- // Ignore the bar.js which should return a 404 for requests made to /bar
358
- ignorePattern: '^.*(?:bar).js$',
359
-
360
- // Set index2.js as the index file which sets the root as /index2
361
- indexPattern: '^index2(?:.js)$',
362
-
363
- // Override default autohooks.js with auto.hooks.js which overrides
364
- // the response body
365
- autoHooksPattern: '^auto.hooks.js$',
366
- autoHooks: true
367
- }
368
- ]
369
- },
370
- watch: false,
371
- metrics: false
372
- }
373
-
374
- const app = await buildServer(config)
375
- teardown(async () => {
376
- await app.close()
377
- })
378
- await app.start()
379
-
380
- {
381
- const res = await request(`${app.url}/`)
382
- equal(res.statusCode, 200, 'status code')
383
- const body = await res.body.json()
384
- equal(body.hello, 'from root', 'body')
385
- }
386
-
387
- {
388
- const res = await request(`${app.url}/foo/bar`)
389
- equal(res.statusCode, 404, 'status code')
390
- }
391
-
392
- {
393
- const res = await request(`${app.url}/foo/baz/index2`)
394
- equal(res.statusCode, 200, 'status code')
395
- const body = await res.body.json()
396
- equal(body.hello, 'from baz with index2.js', 'body')
397
- }
398
-
399
- {
400
- const res = await request(`${app.url}/oof`)
401
- equal(res.statusCode, 200, 'status code')
402
- const body = await res.body.json()
403
- equal(body.hello, 'from auto.hooks.js', 'body')
404
- }
405
- })
406
-
407
- test('autoload with INVALID ignorePattern, indexPattern and autoHooksPattern options', async ({ teardown, equal }) => {
408
- const config = {
409
- server: {
410
- hostname: '127.0.0.1',
411
- port: 0
412
- },
413
- plugins: {
414
- paths: [
415
- {
416
- path: join(__dirname, 'fixtures', 'directories', 'routes'),
417
- ignorePattern: '***',
418
- indexPattern: '***terrible)))_pattern',
419
- autoHooksPattern: ''
420
- }
421
- ]
422
- },
423
- watch: false,
424
- metrics: false
425
- }
426
-
427
- const app = await buildServer(config)
428
- teardown(async () => {
429
- await app.close()
430
- })
431
- await app.start()
432
-
433
- {
434
- const res = await request(`${app.url}/`)
435
- equal(res.statusCode, 200, 'status code')
436
- }
437
- })
438
-
439
- test('loads encapsulated plugin twice', async ({ teardown, equal, strictSame }) => {
440
- const config = {
441
- server: {
442
- hostname: '127.0.0.1',
443
- port: 0,
444
- // Windows CI is slow
445
- pluginTimeout: 60 * 1000
446
- },
447
- service: {
448
- openapi: true
449
- },
450
- plugins: {
451
- paths: [{
452
- path: join(__dirname, 'fixtures', 'directories', 'routes')
453
- }, {
454
- path: join(__dirname, 'fixtures', 'directories', 'plugins', 'decorator.js')
455
- }]
456
- }
457
- }
458
-
459
- {
460
- // First time plugin is loaded from file
461
- const app = await buildServer(config)
462
- teardown(async () => {
463
- await app.close()
464
- })
465
- await app.start()
466
-
467
- const res = await request(`${app.url}/foo/with-decorator`)
468
- equal(res.statusCode, 200, 'status code')
469
- const body = await res.body.json()
470
- strictSame(body, { hello: 'bar' })
471
- }
472
-
473
- {
474
- // Second time plugin is loaded from cache
475
- const app = await buildServer(config)
476
- teardown(async () => {
477
- await app.close()
478
- })
479
- await app.start()
480
-
481
- const res = await request(`${app.url}/foo/with-decorator`)
482
- equal(res.statusCode, 200, 'status code')
483
- const body = await res.body.json()
484
- strictSame(body, { hello: 'bar' })
485
- }
486
- })