@platformatic/next 2.0.0-alpha.5

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 (46) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +13 -0
  3. package/README.md +13 -0
  4. package/config.d.ts +156 -0
  5. package/eslint.config.js +5 -0
  6. package/index.js +135 -0
  7. package/lib/loader.js +137 -0
  8. package/lib/schema.js +26 -0
  9. package/package.json +48 -0
  10. package/schema.json +506 -0
  11. package/test/fixtures/next/composer-autodetect-prefix/next.config.mjs +5 -0
  12. package/test/fixtures/next/composer-autodetect-prefix/package.json +15 -0
  13. package/test/fixtures/next/composer-autodetect-prefix/platformatic.application.json +8 -0
  14. package/test/fixtures/next/composer-autodetect-prefix/platformatic.runtime.json +20 -0
  15. package/test/fixtures/next/composer-autodetect-prefix/src/app/layout.js +7 -0
  16. package/test/fixtures/next/composer-autodetect-prefix/src/app/page.js +5 -0
  17. package/test/fixtures/next/composer-with-prefix/next.config.js +1 -0
  18. package/test/fixtures/next/composer-with-prefix/package.json +15 -0
  19. package/test/fixtures/next/composer-with-prefix/platformatic.application.json +11 -0
  20. package/test/fixtures/next/composer-with-prefix/platformatic.runtime.json +21 -0
  21. package/test/fixtures/next/composer-with-prefix/src/app/layout.js +7 -0
  22. package/test/fixtures/next/composer-with-prefix/src/app/page.js +5 -0
  23. package/test/fixtures/next/composer-without-prefix/next.config.mjs +3 -0
  24. package/test/fixtures/next/composer-without-prefix/package.json +15 -0
  25. package/test/fixtures/next/composer-without-prefix/platformatic.application.json +8 -0
  26. package/test/fixtures/next/composer-without-prefix/platformatic.runtime.json +21 -0
  27. package/test/fixtures/next/composer-without-prefix/src/app/layout.js +7 -0
  28. package/test/fixtures/next/composer-without-prefix/src/app/page.js +5 -0
  29. package/test/fixtures/next/server-side/next.config.js +1 -0
  30. package/test/fixtures/next/server-side/package.json +15 -0
  31. package/test/fixtures/next/server-side/platformatic.application.json +11 -0
  32. package/test/fixtures/next/server-side/platformatic.runtime.json +21 -0
  33. package/test/fixtures/next/server-side/src/app/direct/route.js +3 -0
  34. package/test/fixtures/next/server-side/src/app/layout.js +7 -0
  35. package/test/fixtures/next/server-side/src/app/page.js +12 -0
  36. package/test/fixtures/next/standalone/next.config.mjs +3 -0
  37. package/test/fixtures/next/standalone/package.json +15 -0
  38. package/test/fixtures/next/standalone/platformatic.runtime.json +18 -0
  39. package/test/fixtures/next/standalone/src/app/layout.js +7 -0
  40. package/test/fixtures/next/standalone/src/app/page.js +5 -0
  41. package/test/fixtures/platformatic-composer/platformatic.composer.json +20 -0
  42. package/test/fixtures/platformatic-composer/platformatic.no-prefix.composer.json +23 -0
  43. package/test/fixtures/platformatic-composer/plugin.js +9 -0
  44. package/test/fixtures/platformatic-service/platformatic.service.json +15 -0
  45. package/test/fixtures/platformatic-service/plugin.js +19 -0
  46. package/test/index.test.js +131 -0
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@platformatic/next",
3
+ "version": "2.0.0-alpha.5",
4
+ "description": "Platformatic Next.js Stackable",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/platformatic/platformatic.git"
10
+ },
11
+ "author": "Paolo Insogna <paolo@cowtech.it>",
12
+ "license": "Apache-2.0",
13
+ "bugs": {
14
+ "url": "https://github.com/platformatic/platformatic/issues"
15
+ },
16
+ "homepage": "https://github.com/platformatic/platformatic#readme",
17
+ "dependencies": {
18
+ "@babel/generator": "^7.25.0",
19
+ "@babel/parser": "^7.25.3",
20
+ "@babel/traverse": "^7.25.3",
21
+ "@babel/types": "^7.25.2",
22
+ "semver": "^7.6.3",
23
+ "@platformatic/basic": "2.0.0-alpha.5",
24
+ "@platformatic/utils": "2.0.0-alpha.5",
25
+ "@platformatic/config": "2.0.0-alpha.5"
26
+ },
27
+ "devDependencies": {
28
+ "borp": "^0.17.0",
29
+ "eslint": "9",
30
+ "neostandard": "^0.11.1",
31
+ "next": "^14.2.5",
32
+ "react": "^18.3.1",
33
+ "react-dom": "^18.3.1",
34
+ "json-schema-to-typescript": "^15.0.0",
35
+ "typescript": "^5.5.4",
36
+ "ws": "^8.18.0",
37
+ "@platformatic/composer": "2.0.0-alpha.5",
38
+ "@platformatic/service": "2.0.0-alpha.5"
39
+ },
40
+ "scripts": {
41
+ "test": "npm run lint && borp --concurrency=1 --timeout=180000",
42
+ "coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout=180000",
43
+ "gen-schema": "node lib/schema.js > schema.json",
44
+ "gen-types": "json2ts > config.d.ts < schema.json",
45
+ "build": "pnpm run gen-schema && pnpm run gen-types",
46
+ "lint": "eslint"
47
+ }
48
+ }
package/schema.json ADDED
@@ -0,0 +1,506 @@
1
+ {
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/next/2.0.0-alpha.5.json",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Platformatic Next.js Stackable",
5
+ "type": "object",
6
+ "properties": {
7
+ "$schema": {
8
+ "type": "string"
9
+ },
10
+ "server": {
11
+ "type": "object",
12
+ "properties": {
13
+ "hostname": {
14
+ "type": "string"
15
+ },
16
+ "port": {
17
+ "anyOf": [
18
+ {
19
+ "type": "integer"
20
+ },
21
+ {
22
+ "type": "string"
23
+ }
24
+ ]
25
+ },
26
+ "pluginTimeout": {
27
+ "type": "integer"
28
+ },
29
+ "healthCheck": {
30
+ "anyOf": [
31
+ {
32
+ "type": "boolean"
33
+ },
34
+ {
35
+ "type": "object",
36
+ "properties": {
37
+ "enabled": {
38
+ "type": "boolean"
39
+ },
40
+ "interval": {
41
+ "type": "integer"
42
+ }
43
+ },
44
+ "additionalProperties": true
45
+ }
46
+ ]
47
+ },
48
+ "ignoreTrailingSlash": {
49
+ "type": "boolean"
50
+ },
51
+ "ignoreDuplicateSlashes": {
52
+ "type": "boolean"
53
+ },
54
+ "connectionTimeout": {
55
+ "type": "integer"
56
+ },
57
+ "keepAliveTimeout": {
58
+ "type": "integer",
59
+ "default": 5000
60
+ },
61
+ "maxRequestsPerSocket": {
62
+ "type": "integer"
63
+ },
64
+ "forceCloseConnections": {
65
+ "anyOf": [
66
+ {
67
+ "type": "boolean"
68
+ },
69
+ {
70
+ "type": "string",
71
+ "pattern": "^idle$"
72
+ }
73
+ ]
74
+ },
75
+ "requestTimeout": {
76
+ "type": "integer"
77
+ },
78
+ "bodyLimit": {
79
+ "type": "integer"
80
+ },
81
+ "maxParamLength": {
82
+ "type": "integer"
83
+ },
84
+ "disableRequestLogging": {
85
+ "type": "boolean"
86
+ },
87
+ "exposeHeadRoutes": {
88
+ "type": "boolean"
89
+ },
90
+ "logger": {
91
+ "anyOf": [
92
+ {
93
+ "type": "boolean"
94
+ },
95
+ {
96
+ "type": "object",
97
+ "properties": {
98
+ "level": {
99
+ "type": "string"
100
+ },
101
+ "transport": {
102
+ "anyOf": [
103
+ {
104
+ "type": "object",
105
+ "properties": {
106
+ "target": {
107
+ "type": "string",
108
+ "resolveModule": true
109
+ },
110
+ "options": {
111
+ "type": "object"
112
+ }
113
+ },
114
+ "additionalProperties": false
115
+ },
116
+ {
117
+ "type": "object",
118
+ "properties": {
119
+ "targets": {
120
+ "type": "array",
121
+ "items": {
122
+ "type": "object",
123
+ "properties": {
124
+ "target": {
125
+ "type": "string",
126
+ "resolveModule": true
127
+ },
128
+ "options": {
129
+ "type": "object"
130
+ },
131
+ "level": {
132
+ "type": "string"
133
+ },
134
+ "additionalProperties": false
135
+ }
136
+ }
137
+ },
138
+ "options": {
139
+ "type": "object"
140
+ }
141
+ },
142
+ "additionalProperties": false
143
+ }
144
+ ]
145
+ },
146
+ "pipeline": {
147
+ "type": "object",
148
+ "properties": {
149
+ "target": {
150
+ "type": "string",
151
+ "resolveModule": true
152
+ },
153
+ "options": {
154
+ "type": "object"
155
+ }
156
+ },
157
+ "additionalProperties": false
158
+ }
159
+ },
160
+ "additionalProperties": true
161
+ }
162
+ ]
163
+ },
164
+ "serializerOpts": {
165
+ "type": "object",
166
+ "properties": {
167
+ "schema": {
168
+ "type": "object"
169
+ },
170
+ "ajv": {
171
+ "type": "object"
172
+ },
173
+ "rounding": {
174
+ "type": "string",
175
+ "enum": [
176
+ "floor",
177
+ "ceil",
178
+ "round",
179
+ "trunc"
180
+ ],
181
+ "default": "trunc"
182
+ },
183
+ "debugMode": {
184
+ "type": "boolean"
185
+ },
186
+ "mode": {
187
+ "type": "string",
188
+ "enum": [
189
+ "debug",
190
+ "standalone"
191
+ ]
192
+ },
193
+ "largeArraySize": {
194
+ "anyOf": [
195
+ {
196
+ "type": "integer"
197
+ },
198
+ {
199
+ "type": "string"
200
+ }
201
+ ],
202
+ "default": 20000
203
+ },
204
+ "largeArrayMechanism": {
205
+ "type": "string",
206
+ "enum": [
207
+ "default",
208
+ "json-stringify"
209
+ ],
210
+ "default": "default"
211
+ }
212
+ }
213
+ },
214
+ "caseSensitive": {
215
+ "type": "boolean"
216
+ },
217
+ "requestIdHeader": {
218
+ "anyOf": [
219
+ {
220
+ "type": "string"
221
+ },
222
+ {
223
+ "type": "boolean",
224
+ "const": false
225
+ }
226
+ ]
227
+ },
228
+ "requestIdLogLabel": {
229
+ "type": "string"
230
+ },
231
+ "jsonShorthand": {
232
+ "type": "boolean"
233
+ },
234
+ "trustProxy": {
235
+ "anyOf": [
236
+ {
237
+ "type": "boolean"
238
+ },
239
+ {
240
+ "type": "string"
241
+ },
242
+ {
243
+ "type": "array",
244
+ "items": {
245
+ "type": "string"
246
+ }
247
+ },
248
+ {
249
+ "type": "integer"
250
+ }
251
+ ]
252
+ },
253
+ "http2": {
254
+ "type": "boolean"
255
+ },
256
+ "https": {
257
+ "type": "object",
258
+ "properties": {
259
+ "allowHTTP1": {
260
+ "type": "boolean"
261
+ },
262
+ "key": {
263
+ "anyOf": [
264
+ {
265
+ "type": "string"
266
+ },
267
+ {
268
+ "type": "object",
269
+ "properties": {
270
+ "path": {
271
+ "type": "string",
272
+ "resolvePath": true
273
+ }
274
+ },
275
+ "additionalProperties": false
276
+ },
277
+ {
278
+ "type": "array",
279
+ "items": {
280
+ "anyOf": [
281
+ {
282
+ "type": "string"
283
+ },
284
+ {
285
+ "type": "object",
286
+ "properties": {
287
+ "path": {
288
+ "type": "string",
289
+ "resolvePath": true
290
+ }
291
+ },
292
+ "additionalProperties": false
293
+ }
294
+ ]
295
+ }
296
+ }
297
+ ]
298
+ },
299
+ "cert": {
300
+ "anyOf": [
301
+ {
302
+ "type": "string"
303
+ },
304
+ {
305
+ "type": "object",
306
+ "properties": {
307
+ "path": {
308
+ "type": "string",
309
+ "resolvePath": true
310
+ }
311
+ },
312
+ "additionalProperties": false
313
+ },
314
+ {
315
+ "type": "array",
316
+ "items": {
317
+ "anyOf": [
318
+ {
319
+ "type": "string"
320
+ },
321
+ {
322
+ "type": "object",
323
+ "properties": {
324
+ "path": {
325
+ "type": "string",
326
+ "resolvePath": true
327
+ }
328
+ },
329
+ "additionalProperties": false
330
+ }
331
+ ]
332
+ }
333
+ }
334
+ ]
335
+ },
336
+ "requestCert": {
337
+ "type": "boolean"
338
+ },
339
+ "rejectUnauthorized": {
340
+ "type": "boolean"
341
+ }
342
+ },
343
+ "additionalProperties": false,
344
+ "required": [
345
+ "key",
346
+ "cert"
347
+ ]
348
+ },
349
+ "cors": {
350
+ "type": "object",
351
+ "$comment": "See https://github.com/fastify/fastify-cors",
352
+ "properties": {
353
+ "origin": {
354
+ "anyOf": [
355
+ {
356
+ "type": "boolean"
357
+ },
358
+ {
359
+ "type": "string"
360
+ },
361
+ {
362
+ "type": "array",
363
+ "items": {
364
+ "anyOf": [
365
+ {
366
+ "type": "string"
367
+ },
368
+ {
369
+ "type": "object",
370
+ "properties": {
371
+ "regexp": {
372
+ "type": "string"
373
+ }
374
+ },
375
+ "required": [
376
+ "regexp"
377
+ ]
378
+ }
379
+ ]
380
+ }
381
+ },
382
+ {
383
+ "type": "object",
384
+ "properties": {
385
+ "regexp": {
386
+ "type": "string"
387
+ }
388
+ },
389
+ "required": [
390
+ "regexp"
391
+ ]
392
+ }
393
+ ]
394
+ },
395
+ "methods": {
396
+ "type": "array",
397
+ "items": {
398
+ "type": "string"
399
+ }
400
+ },
401
+ "allowedHeaders": {
402
+ "type": "string",
403
+ "description": "Comma separated string of allowed headers."
404
+ },
405
+ "exposedHeaders": {
406
+ "anyOf": [
407
+ {
408
+ "type": "array",
409
+ "items": {
410
+ "type": "string"
411
+ }
412
+ },
413
+ {
414
+ "type": "string",
415
+ "description": "Comma separated string of exposed headers."
416
+ }
417
+ ]
418
+ },
419
+ "credentials": {
420
+ "type": "boolean"
421
+ },
422
+ "maxAge": {
423
+ "type": "integer"
424
+ },
425
+ "preflightContinue": {
426
+ "type": "boolean",
427
+ "default": false
428
+ },
429
+ "optionsSuccessStatus": {
430
+ "type": "integer",
431
+ "default": 204
432
+ },
433
+ "preflight": {
434
+ "type": "boolean",
435
+ "default": true
436
+ },
437
+ "strictPreflight": {
438
+ "type": "boolean",
439
+ "default": true
440
+ },
441
+ "hideOptionsRoute": {
442
+ "type": "boolean",
443
+ "default": true
444
+ }
445
+ },
446
+ "additionalProperties": false
447
+ }
448
+ },
449
+ "additionalProperties": false
450
+ },
451
+ "watch": {
452
+ "anyOf": [
453
+ {
454
+ "type": "object",
455
+ "properties": {
456
+ "enabled": {
457
+ "default": true,
458
+ "anyOf": [
459
+ {
460
+ "type": "boolean"
461
+ },
462
+ {
463
+ "type": "string"
464
+ }
465
+ ]
466
+ },
467
+ "allow": {
468
+ "type": "array",
469
+ "items": {
470
+ "type": "string"
471
+ },
472
+ "minItems": 1,
473
+ "nullable": true,
474
+ "default": null
475
+ },
476
+ "ignore": {
477
+ "type": "array",
478
+ "items": {
479
+ "type": "string"
480
+ },
481
+ "nullable": true,
482
+ "default": null
483
+ }
484
+ },
485
+ "additionalProperties": false
486
+ },
487
+ {
488
+ "type": "boolean"
489
+ },
490
+ {
491
+ "type": "string"
492
+ }
493
+ ]
494
+ },
495
+ "application": {
496
+ "type": "object",
497
+ "properties": {
498
+ "basePath": {
499
+ "type": "string"
500
+ }
501
+ },
502
+ "additionalProperties": false
503
+ }
504
+ },
505
+ "additionalProperties": false
506
+ }
@@ -0,0 +1,5 @@
1
+ const nextConfig = {
2
+ basePath: '/nested/base/dir',
3
+ }
4
+
5
+ export default nextConfig
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "next",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.0.0",
12
+ "react-dom": "^18.0.0",
13
+ "next": "^14.2.5"
14
+ }
15
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://schemas.platformatic.dev/@platformatic/next/2.0.0.json",
3
+ "server": {
4
+ "logger": {
5
+ "level": "error"
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
+ "entrypoint": "main",
4
+ "watch": false,
5
+ "managementApi": false,
6
+ "metrics": false,
7
+ "server": {
8
+ "logger": {
9
+ "level": "error"
10
+ }
11
+ },
12
+ "services": [
13
+ {
14
+ "id": "frontend",
15
+ "path": "."
16
+ },
17
+ { "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
18
+ { "id": "main", "config": "platformatic.no-prefix.composer.json", "path": "../../platformatic-composer" }
19
+ ]
20
+ }
@@ -0,0 +1,7 @@
1
+ export default function RootLayout ({ children }) {
2
+ return (
3
+ <html lang='en'>
4
+ <body>{children}</body>
5
+ </html>
6
+ )
7
+ }
@@ -0,0 +1,5 @@
1
+ import { version } from '../../../../../tmp/version.js'
2
+
3
+ export default function Home () {
4
+ return <div>Hello from {version}</div>
5
+ }
@@ -0,0 +1 @@
1
+ module.exports = {}
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "next",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start"
9
+ },
10
+ "dependencies": {
11
+ "react": "^18.0.0",
12
+ "react-dom": "^18.0.0",
13
+ "next": "^14.2.5"
14
+ }
15
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://schemas.platformatic.dev/@platformatic/next/2.0.0.json",
3
+ "server": {
4
+ "logger": {
5
+ "level": "error"
6
+ }
7
+ },
8
+ "application": {
9
+ "basePath": "/frontend"
10
+ }
11
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
+ "entrypoint": "main",
4
+ "watch": false,
5
+ "managementApi": false,
6
+ "metrics": false,
7
+ "server": {
8
+ "logger": {
9
+ "level": "error"
10
+ }
11
+ },
12
+ "services": [
13
+ {
14
+ "id": "frontend",
15
+ "path": ".",
16
+ "config": "platformatic.application.json"
17
+ },
18
+ { "id": "service", "config": "platformatic.service.json", "path": "../../platformatic-service" },
19
+ { "id": "main", "config": "platformatic.composer.json", "path": "../../platformatic-composer" }
20
+ ]
21
+ }
@@ -0,0 +1,7 @@
1
+ export default function RootLayout ({ children }) {
2
+ return (
3
+ <html lang='en'>
4
+ <body>{children}</body>
5
+ </html>
6
+ )
7
+ }
@@ -0,0 +1,5 @@
1
+ import { version } from '../../../../../tmp/version.js'
2
+
3
+ export default function Home () {
4
+ return <div>Hello from {version}</div>
5
+ }