@platformatic/nuxt 0.0.1 → 3.58.1
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/LICENSE +201 -0
- package/README.md +26 -0
- package/config.d.ts +749 -0
- package/eslint.config.js +3 -0
- package/index.d.ts +35 -0
- package/index.js +31 -0
- package/lib/capability.js +255 -0
- package/lib/schema.js +50 -0
- package/package.json +39 -18
- package/schema.json +2805 -0
- package/test/backlog.test.js +88 -0
- package/test/development.test.js +216 -0
- package/test/fetch.test.js +67 -0
- package/test/fixtures/composer-autodetect-prefix/package.json +10 -0
- package/test/fixtures/composer-autodetect-prefix/platformatic.runtime.json +24 -0
- package/test/fixtures/composer-autodetect-prefix/services/frontend/app.vue +8 -0
- package/test/fixtures/composer-autodetect-prefix/services/frontend/nuxt.config.js +16 -0
- package/test/fixtures/composer-autodetect-prefix/services/frontend/package.json +9 -0
- package/test/fixtures/composer-autodetect-prefix/services/frontend/platformatic.application.json +6 -0
- package/test/fixtures/composer-custom-commands/package.json +11 -0
- package/test/fixtures/composer-custom-commands/platformatic.runtime.json +24 -0
- package/test/fixtures/composer-custom-commands/services/frontend/app.vue +8 -0
- package/test/fixtures/composer-custom-commands/services/frontend/nuxt.config.js +16 -0
- package/test/fixtures/composer-custom-commands/services/frontend/package.json +16 -0
- package/test/fixtures/composer-custom-commands/services/frontend/platformatic.application.json +11 -0
- package/test/fixtures/composer-with-prefix/package.json +10 -0
- package/test/fixtures/composer-with-prefix/platformatic.runtime.json +24 -0
- package/test/fixtures/composer-with-prefix/services/frontend/app.vue +8 -0
- package/test/fixtures/composer-with-prefix/services/frontend/nuxt.config.js +16 -0
- package/test/fixtures/composer-with-prefix/services/frontend/package.json +9 -0
- package/test/fixtures/composer-with-prefix/services/frontend/platformatic.application.json +6 -0
- package/test/fixtures/composer-without-prefix/package.json +10 -0
- package/test/fixtures/composer-without-prefix/platformatic.runtime.json +24 -0
- package/test/fixtures/composer-without-prefix/services/frontend/app.vue +8 -0
- package/test/fixtures/composer-without-prefix/services/frontend/nuxt.config.js +13 -0
- package/test/fixtures/composer-without-prefix/services/frontend/package.json +9 -0
- package/test/fixtures/composer-without-prefix/services/frontend/platformatic.application.json +3 -0
- package/test/fixtures/fetch-test/package.json +10 -0
- package/test/fixtures/fetch-test/platformatic.runtime.json +24 -0
- package/test/fixtures/fetch-test/services/frontend/app.vue +29 -0
- package/test/fixtures/fetch-test/services/frontend/nuxt.config.js +15 -0
- package/test/fixtures/fetch-test/services/frontend/package.json +9 -0
- package/test/fixtures/fetch-test/services/frontend/platformatic.application.json +6 -0
- package/test/fixtures/logger/package.json +8 -0
- package/test/fixtures/logger/platformatic.runtime.json +15 -0
- package/test/fixtures/logger/services/frontend/app.vue +12 -0
- package/test/fixtures/logger/services/frontend/logger-formatters.js +7 -0
- package/test/fixtures/logger/services/frontend/nuxt.config.js +12 -0
- package/test/fixtures/logger/services/frontend/package.json +9 -0
- package/test/fixtures/logger/services/frontend/platformatic.application.json +14 -0
- package/test/fixtures/metrics/package.json +10 -0
- package/test/fixtures/metrics/platformatic.runtime.json +25 -0
- package/test/fixtures/metrics/services/backend/package.json +6 -0
- package/test/fixtures/metrics/services/backend/platformatic.json +16 -0
- package/test/fixtures/metrics/services/backend/plugins/example.js +3 -0
- package/test/fixtures/metrics/services/backend/routes/root.js +30 -0
- package/test/fixtures/metrics/services/composer/package.json +6 -0
- package/test/fixtures/metrics/services/composer/platformatic.json +14 -0
- package/test/fixtures/metrics/services/frontend/app.vue +8 -0
- package/test/fixtures/metrics/services/frontend/nuxt.config.js +15 -0
- package/test/fixtures/metrics/services/frontend/package.json +9 -0
- package/test/fixtures/metrics/services/frontend/platformatic.application.json +6 -0
- package/test/fixtures/ssr-autodetect-prefix/package.json +10 -0
- package/test/fixtures/ssr-autodetect-prefix/platformatic.runtime.json +24 -0
- package/test/fixtures/ssr-autodetect-prefix/services/frontend/app.vue +8 -0
- package/test/fixtures/ssr-autodetect-prefix/services/frontend/nuxt.config.js +15 -0
- package/test/fixtures/ssr-autodetect-prefix/services/frontend/package.json +9 -0
- package/test/fixtures/ssr-autodetect-prefix/services/frontend/platformatic.application.json +6 -0
- package/test/fixtures/ssr-custom-commands/package.json +11 -0
- package/test/fixtures/ssr-custom-commands/platformatic.runtime.json +24 -0
- package/test/fixtures/ssr-custom-commands/services/frontend/app.vue +8 -0
- package/test/fixtures/ssr-custom-commands/services/frontend/nuxt.config.js +15 -0
- package/test/fixtures/ssr-custom-commands/services/frontend/package.json +16 -0
- package/test/fixtures/ssr-custom-commands/services/frontend/platformatic.application.json +11 -0
- package/test/fixtures/ssr-standalone/package.json +8 -0
- package/test/fixtures/ssr-standalone/platformatic.runtime.json +15 -0
- package/test/fixtures/ssr-standalone/services/frontend/app.vue +8 -0
- package/test/fixtures/ssr-standalone/services/frontend/nuxt.config.js +12 -0
- package/test/fixtures/ssr-standalone/services/frontend/package.json +9 -0
- package/test/fixtures/ssr-standalone/services/frontend/platformatic.application.json +3 -0
- package/test/fixtures/ssr-with-prefix/package.json +10 -0
- package/test/fixtures/ssr-with-prefix/platformatic.runtime.json +24 -0
- package/test/fixtures/ssr-with-prefix/services/frontend/app.vue +8 -0
- package/test/fixtures/ssr-with-prefix/services/frontend/nuxt.config.js +15 -0
- package/test/fixtures/ssr-with-prefix/services/frontend/package.json +9 -0
- package/test/fixtures/ssr-with-prefix/services/frontend/platformatic.application.json +6 -0
- package/test/fixtures/ssr-without-prefix/package.json +10 -0
- package/test/fixtures/ssr-without-prefix/platformatic.runtime.json +24 -0
- package/test/fixtures/ssr-without-prefix/services/frontend/app.vue +8 -0
- package/test/fixtures/ssr-without-prefix/services/frontend/nuxt.config.js +12 -0
- package/test/fixtures/ssr-without-prefix/services/frontend/package.json +9 -0
- package/test/fixtures/ssr-without-prefix/services/frontend/platformatic.application.json +3 -0
- package/test/fixtures/standalone/package.json +8 -0
- package/test/fixtures/standalone/platformatic.runtime.json +15 -0
- package/test/fixtures/standalone/services/frontend/app.vue +8 -0
- package/test/fixtures/standalone/services/frontend/nuxt.config.js +13 -0
- package/test/fixtures/standalone/services/frontend/package.json +9 -0
- package/test/fixtures/standalone/services/frontend/platformatic.application.json +3 -0
- package/test/helper.js +1 -0
- package/test/https.test.js +43 -0
- package/test/logger.test.js +31 -0
- package/test/metrics.test.js +46 -0
- package/test/miscellaneous.test.js +33 -0
- package/test/production.test.js +153 -0
- package/test/types/index.tst.ts +34 -0
- package/test/version-check.test.js +29 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { deepStrictEqual } from 'node:assert'
|
|
2
|
+
import { cp } from 'node:fs/promises'
|
|
3
|
+
import path, { resolve } from 'node:path'
|
|
4
|
+
import { test } from 'node:test'
|
|
5
|
+
import { commonFixturesRoot, prepareRuntime, updateFile } from '../../basic/test/helper.js'
|
|
6
|
+
import { updateConfigFile } from '../../runtime/test/helpers.js'
|
|
7
|
+
|
|
8
|
+
const envs = {
|
|
9
|
+
dev: {
|
|
10
|
+
build: false,
|
|
11
|
+
production: false
|
|
12
|
+
},
|
|
13
|
+
production: {
|
|
14
|
+
build: true,
|
|
15
|
+
production: true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function waitServerOptions (runtime) {
|
|
20
|
+
const { promise, resolve } = Promise.withResolvers()
|
|
21
|
+
|
|
22
|
+
function listener (payload, _, application) {
|
|
23
|
+
if (application === 'frontend') {
|
|
24
|
+
runtime.removeListener('application:worker:event:serverOptions', listener)
|
|
25
|
+
resolve(payload)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
runtime.on('application:worker:event:serverOptions', listener)
|
|
30
|
+
|
|
31
|
+
return promise
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (const [env, options] of Object.entries(envs)) {
|
|
35
|
+
test(`Nuxt application should properly use backlog option in ${env}`, async t => {
|
|
36
|
+
const { runtime } = await prepareRuntime({
|
|
37
|
+
t,
|
|
38
|
+
root: path.resolve(import.meta.dirname, './fixtures/standalone'),
|
|
39
|
+
build: options.build,
|
|
40
|
+
production: options.production,
|
|
41
|
+
async additionalSetup (root) {
|
|
42
|
+
return updateConfigFile(resolve(root, 'services/frontend/platformatic.application.json'), config => {
|
|
43
|
+
config.server ??= {}
|
|
44
|
+
config.server.backlog = 100
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const promise = waitServerOptions(runtime)
|
|
50
|
+
|
|
51
|
+
await runtime.start()
|
|
52
|
+
const serverOptions = await promise
|
|
53
|
+
deepStrictEqual(serverOptions.backlog, 100)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test(`Nuxt application should properly use backlog option in ${env} when using custom commands`, async t => {
|
|
57
|
+
const { runtime } = await prepareRuntime({
|
|
58
|
+
t,
|
|
59
|
+
root: path.resolve(import.meta.dirname, './fixtures/composer-custom-commands'),
|
|
60
|
+
build: options.build,
|
|
61
|
+
production: options.production,
|
|
62
|
+
async additionalSetup (root, config) {
|
|
63
|
+
for (const type of ['backend', 'composer']) {
|
|
64
|
+
await cp(resolve(commonFixturesRoot, `${type}-js`), resolve(root, `services/${type}`), {
|
|
65
|
+
recursive: true
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
await updateFile(resolve(root, 'services/composer/routes/root.js'), contents => {
|
|
70
|
+
return contents.replace('$PREFIX', '/frontend')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
await updateConfigFile(resolve(root, 'services/frontend/platformatic.application.json'), config => {
|
|
74
|
+
config.server ??= {}
|
|
75
|
+
config.server.backlog = 100
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
config.applications[0].useHttp = true
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const promise = waitServerOptions(runtime)
|
|
83
|
+
|
|
84
|
+
await runtime.start()
|
|
85
|
+
const serverOptions = await promise
|
|
86
|
+
deepStrictEqual(serverOptions.backlog, 100)
|
|
87
|
+
})
|
|
88
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import {
|
|
3
|
+
createRuntime,
|
|
4
|
+
prepareRuntimeWithApplications,
|
|
5
|
+
setAdditionalDependencies,
|
|
6
|
+
setFixturesDir,
|
|
7
|
+
updateFile,
|
|
8
|
+
verifyDevelopmentMode,
|
|
9
|
+
verifyHTMLViaHTTP,
|
|
10
|
+
verifyHTMLViaInject,
|
|
11
|
+
verifyJSONViaHTTP,
|
|
12
|
+
verifyJSONViaInject
|
|
13
|
+
} from '../../basic/test/helper.js'
|
|
14
|
+
import { additionalDependencies } from './helper.js'
|
|
15
|
+
|
|
16
|
+
process.setMaxListeners(100)
|
|
17
|
+
setFixturesDir(resolve(import.meta.dirname, './fixtures'))
|
|
18
|
+
setAdditionalDependencies(additionalDependencies)
|
|
19
|
+
|
|
20
|
+
const htmlContents = ['<script>window.__NUXT__={}']
|
|
21
|
+
const htmlContentsSSR = [/Hello from v\d+ t\d+/]
|
|
22
|
+
|
|
23
|
+
async function verifyStandalone (
|
|
24
|
+
t,
|
|
25
|
+
configuration,
|
|
26
|
+
_language,
|
|
27
|
+
htmlContents,
|
|
28
|
+
_hmrUrl,
|
|
29
|
+
_hmrProtocol,
|
|
30
|
+
_websocketHMRHandler,
|
|
31
|
+
pauseTimeout,
|
|
32
|
+
additionalSetup
|
|
33
|
+
) {
|
|
34
|
+
const { url } = await createRuntime(t, configuration, pauseTimeout, false, null, additionalSetup)
|
|
35
|
+
await verifyHTMLViaHTTP(url, '/', htmlContents)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function verifyComposerWithPrefix (
|
|
39
|
+
t,
|
|
40
|
+
configuration,
|
|
41
|
+
language,
|
|
42
|
+
htmlContents,
|
|
43
|
+
_hmrUrl,
|
|
44
|
+
_hmrProtocol,
|
|
45
|
+
_websocketHMRHandler,
|
|
46
|
+
pauseTimeout,
|
|
47
|
+
additionalSetup
|
|
48
|
+
) {
|
|
49
|
+
const { runtime, url } = await prepareRuntimeWithApplications(
|
|
50
|
+
t,
|
|
51
|
+
configuration,
|
|
52
|
+
false,
|
|
53
|
+
language,
|
|
54
|
+
'/frontend',
|
|
55
|
+
pauseTimeout,
|
|
56
|
+
additionalSetup
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
await verifyHTMLViaHTTP(url, '/frontend/', htmlContents)
|
|
60
|
+
await verifyHTMLViaInject(runtime, 'composer', '/frontend', htmlContents)
|
|
61
|
+
|
|
62
|
+
await verifyJSONViaHTTP(url, '/example', 200, { hello: 'foobar' })
|
|
63
|
+
await verifyJSONViaHTTP(url, '/frontend/on-composer', 200, { ok: true })
|
|
64
|
+
await verifyJSONViaHTTP(url, '/backend/example', 200, { hello: 'foobar' })
|
|
65
|
+
|
|
66
|
+
await verifyJSONViaInject(runtime, 'composer', 'GET', '/example', 200, { hello: 'foobar' })
|
|
67
|
+
await verifyJSONViaInject(runtime, 'composer', 'GET', '/frontend/on-composer', 200, { ok: true })
|
|
68
|
+
await verifyJSONViaInject(runtime, 'backend', 'GET', '/example', 200, { hello: 'foobar' })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function verifyComposerWithoutPrefix (
|
|
72
|
+
t,
|
|
73
|
+
configuration,
|
|
74
|
+
language,
|
|
75
|
+
htmlContents,
|
|
76
|
+
_hmrUrl,
|
|
77
|
+
_hmrProtocol,
|
|
78
|
+
_websocketHMRHandler,
|
|
79
|
+
pauseTimeout,
|
|
80
|
+
additionalSetup
|
|
81
|
+
) {
|
|
82
|
+
const { runtime, url } = await prepareRuntimeWithApplications(
|
|
83
|
+
t,
|
|
84
|
+
configuration,
|
|
85
|
+
false,
|
|
86
|
+
language,
|
|
87
|
+
'',
|
|
88
|
+
pauseTimeout,
|
|
89
|
+
async root => {
|
|
90
|
+
await updateFile(resolve(root, 'services/composer/platformatic.json'), contents => {
|
|
91
|
+
const json = JSON.parse(contents)
|
|
92
|
+
json.gateway.applications[1].proxy = { prefix: '' }
|
|
93
|
+
return JSON.stringify(json, null, 2)
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
await verifyHTMLViaHTTP(url, '/', htmlContents)
|
|
99
|
+
await verifyHTMLViaInject(runtime, 'composer', '/', htmlContents)
|
|
100
|
+
|
|
101
|
+
await verifyJSONViaHTTP(url, '/example', 200, { hello: 'foobar' })
|
|
102
|
+
await verifyJSONViaHTTP(url, '/on-composer', 200, { ok: true })
|
|
103
|
+
await verifyJSONViaHTTP(url, '/backend/example', 200, { hello: 'foobar' })
|
|
104
|
+
|
|
105
|
+
await verifyJSONViaInject(runtime, 'composer', 'GET', '/example', 200, { hello: 'foobar' })
|
|
106
|
+
await verifyJSONViaInject(runtime, 'composer', 'GET', '/on-composer', 200, { ok: true })
|
|
107
|
+
await verifyJSONViaInject(runtime, 'backend', 'GET', '/example', 200, { hello: 'foobar' })
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function verifyComposerWithAutodetectPrefix (
|
|
111
|
+
t,
|
|
112
|
+
configuration,
|
|
113
|
+
language,
|
|
114
|
+
htmlContents,
|
|
115
|
+
_hmrUrl,
|
|
116
|
+
_hmrProtocol,
|
|
117
|
+
_websocketHMRHandler,
|
|
118
|
+
pauseTimeout,
|
|
119
|
+
additionalSetup
|
|
120
|
+
) {
|
|
121
|
+
const { runtime, url } = await prepareRuntimeWithApplications(
|
|
122
|
+
t,
|
|
123
|
+
configuration,
|
|
124
|
+
false,
|
|
125
|
+
language,
|
|
126
|
+
'/nested/base/dir',
|
|
127
|
+
pauseTimeout,
|
|
128
|
+
additionalSetup
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
await verifyHTMLViaHTTP(url, '/nested/base/dir/', htmlContents)
|
|
132
|
+
await verifyHTMLViaInject(runtime, 'composer', '/nested/base/dir', htmlContents)
|
|
133
|
+
|
|
134
|
+
await verifyJSONViaHTTP(url, '/example', 200, { hello: 'foobar' })
|
|
135
|
+
await verifyJSONViaHTTP(url, '/nested/base/dir/on-composer', 200, { ok: true })
|
|
136
|
+
await verifyJSONViaHTTP(url, '/backend/example', 200, { hello: 'foobar' })
|
|
137
|
+
|
|
138
|
+
await verifyJSONViaInject(runtime, 'composer', 'GET', '/example', 200, { hello: 'foobar' })
|
|
139
|
+
await verifyJSONViaInject(runtime, 'composer', 'GET', '/nested/base/dir/on-composer', 200, { ok: true })
|
|
140
|
+
await verifyJSONViaInject(runtime, 'backend', 'GET', '/example', 200, { hello: 'foobar' })
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const configurations = [
|
|
144
|
+
{
|
|
145
|
+
id: 'standalone',
|
|
146
|
+
name: 'Nuxt (standalone)',
|
|
147
|
+
check: verifyStandalone,
|
|
148
|
+
htmlContents,
|
|
149
|
+
language: 'js'
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 'composer-with-prefix',
|
|
153
|
+
name: 'Nuxt (in composer with prefix)',
|
|
154
|
+
check: verifyComposerWithPrefix,
|
|
155
|
+
htmlContents,
|
|
156
|
+
language: 'js'
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: 'composer-without-prefix',
|
|
160
|
+
name: 'Nuxt (in composer without prefix)',
|
|
161
|
+
check: verifyComposerWithoutPrefix,
|
|
162
|
+
htmlContents,
|
|
163
|
+
language: 'js'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: 'composer-autodetect-prefix',
|
|
167
|
+
name: 'Nuxt (in composer with autodetected prefix)',
|
|
168
|
+
check: verifyComposerWithAutodetectPrefix,
|
|
169
|
+
htmlContents,
|
|
170
|
+
language: 'js'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: 'composer-custom-commands',
|
|
174
|
+
name: 'Nuxt (in composer with prefix using custom commands)',
|
|
175
|
+
check: verifyComposerWithPrefix,
|
|
176
|
+
htmlContents,
|
|
177
|
+
language: 'js'
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: 'ssr-standalone',
|
|
181
|
+
name: 'Nuxt SSR (standalone)',
|
|
182
|
+
check: verifyStandalone,
|
|
183
|
+
htmlContents: htmlContentsSSR,
|
|
184
|
+
language: 'js'
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 'ssr-with-prefix',
|
|
188
|
+
name: 'Nuxt SSR (in composer with prefix)',
|
|
189
|
+
check: verifyComposerWithPrefix,
|
|
190
|
+
htmlContents: htmlContentsSSR,
|
|
191
|
+
language: 'ts'
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: 'ssr-without-prefix',
|
|
195
|
+
name: 'Nuxt SSR (in composer without prefix)',
|
|
196
|
+
check: verifyComposerWithoutPrefix,
|
|
197
|
+
htmlContents: htmlContentsSSR,
|
|
198
|
+
language: 'js'
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: 'ssr-autodetect-prefix',
|
|
202
|
+
name: 'Nuxt SSR (in composer with autodetected prefix)',
|
|
203
|
+
check: verifyComposerWithAutodetectPrefix,
|
|
204
|
+
htmlContents: htmlContentsSSR,
|
|
205
|
+
language: 'js'
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: 'ssr-custom-commands',
|
|
209
|
+
name: 'Nuxt SSR (in composer with prefix using custom commands)',
|
|
210
|
+
check: verifyComposerWithPrefix,
|
|
211
|
+
htmlContents: htmlContentsSSR,
|
|
212
|
+
language: 'js'
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
verifyDevelopmentMode(configurations)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ok, strictEqual } from 'node:assert'
|
|
2
|
+
import { cp } from 'node:fs/promises'
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
import { test } from 'node:test'
|
|
5
|
+
import { request } from 'undici'
|
|
6
|
+
import {
|
|
7
|
+
buildRuntime,
|
|
8
|
+
commonFixturesRoot,
|
|
9
|
+
prepareRuntime,
|
|
10
|
+
setAdditionalDependencies,
|
|
11
|
+
setFixturesDir,
|
|
12
|
+
startRuntime,
|
|
13
|
+
updateFile
|
|
14
|
+
} from '../../basic/test/helper.js'
|
|
15
|
+
import { additionalDependencies } from './helper.js'
|
|
16
|
+
|
|
17
|
+
process.setMaxListeners(100)
|
|
18
|
+
setFixturesDir(resolve(import.meta.dirname, './fixtures'))
|
|
19
|
+
setAdditionalDependencies(additionalDependencies)
|
|
20
|
+
|
|
21
|
+
function decodeHtmlEntities (str) {
|
|
22
|
+
return str
|
|
23
|
+
.replace(/"/g, '"')
|
|
24
|
+
.replace(/&/g, '&')
|
|
25
|
+
.replace(/</g, '<')
|
|
26
|
+
.replace(/>/g, '>')
|
|
27
|
+
.replace(/'/g, "'")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
test('fetch() should work with string URL and Request object in Nuxt app', async t => {
|
|
31
|
+
const { runtime, root } = await prepareRuntime(t, 'fetch-test', true, null, async root => {
|
|
32
|
+
for (const type of ['backend', 'composer']) {
|
|
33
|
+
await cp(resolve(commonFixturesRoot, `${type}-js`), resolve(root, `services/${type}`), {
|
|
34
|
+
recursive: true
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await updateFile(resolve(root, 'services/composer/routes/root.js'), contents => {
|
|
39
|
+
return contents.replace('$PREFIX', '/frontend')
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
await buildRuntime(root)
|
|
44
|
+
|
|
45
|
+
const url = await startRuntime(t, runtime)
|
|
46
|
+
|
|
47
|
+
const response = await request(`${url}/frontend/`)
|
|
48
|
+
strictEqual(response.statusCode, 200, `Expected 200 but got ${response.statusCode}`)
|
|
49
|
+
|
|
50
|
+
const html = await response.body.text()
|
|
51
|
+
ok(html.includes('Hello from v'), 'Page should render successfully')
|
|
52
|
+
|
|
53
|
+
const preMatch = html.match(/<pre[^>]*id="fetch-results"[^>]*>([\s\S]*?)<\/pre>/)
|
|
54
|
+
ok(preMatch, 'Should find fetch-results pre tag')
|
|
55
|
+
|
|
56
|
+
const decoded = decodeHtmlEntities(preMatch[1].trim())
|
|
57
|
+
const fetchResults = JSON.parse(decoded)
|
|
58
|
+
|
|
59
|
+
ok(
|
|
60
|
+
fetchResults.stringUrl?.ok === true,
|
|
61
|
+
`fetch with string URL should succeed: ${JSON.stringify(fetchResults.stringUrl)}`
|
|
62
|
+
)
|
|
63
|
+
ok(
|
|
64
|
+
fetchResults.requestObject?.ok === true,
|
|
65
|
+
`fetch with Request object should succeed: ${JSON.stringify(fetchResults.requestObject)}`
|
|
66
|
+
)
|
|
67
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/2.0.0.json",
|
|
3
|
+
"entrypoint": "composer",
|
|
4
|
+
"services": [
|
|
5
|
+
{
|
|
6
|
+
"id": "frontend",
|
|
7
|
+
"config": "platformatic.application.json",
|
|
8
|
+
"path": "./services/frontend"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "backend",
|
|
12
|
+
"config": "platformatic.json",
|
|
13
|
+
"path": "./services/backend"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "composer",
|
|
17
|
+
"config": "platformatic.json",
|
|
18
|
+
"path": "./services/composer"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"logger": {
|
|
22
|
+
"level": "error"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineNuxtConfig } from 'nuxt/config'
|
|
2
|
+
|
|
3
|
+
export default defineNuxtConfig({
|
|
4
|
+
ssr: false,
|
|
5
|
+
app: {
|
|
6
|
+
baseURL: '/nested/base/dir/'
|
|
7
|
+
},
|
|
8
|
+
compatibilityDate: '2026-06-15',
|
|
9
|
+
telemetry: false,
|
|
10
|
+
devtools: { enabled: false },
|
|
11
|
+
vite: {
|
|
12
|
+
server: {
|
|
13
|
+
allowedHosts: ['.plt.local']
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/2.0.0.json",
|
|
3
|
+
"entrypoint": "composer",
|
|
4
|
+
"services": [
|
|
5
|
+
{
|
|
6
|
+
"id": "frontend",
|
|
7
|
+
"config": "platformatic.application.json",
|
|
8
|
+
"path": "./services/frontend"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "backend",
|
|
12
|
+
"config": "platformatic.json",
|
|
13
|
+
"path": "./services/backend"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "composer",
|
|
17
|
+
"config": "platformatic.json",
|
|
18
|
+
"path": "./services/composer"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"logger": {
|
|
22
|
+
"level": "error"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineNuxtConfig } from 'nuxt/config'
|
|
2
|
+
|
|
3
|
+
export default defineNuxtConfig({
|
|
4
|
+
ssr: false,
|
|
5
|
+
app: {
|
|
6
|
+
baseURL: '/frontend/'
|
|
7
|
+
},
|
|
8
|
+
compatibilityDate: '2026-06-15',
|
|
9
|
+
telemetry: false,
|
|
10
|
+
devtools: { enabled: false },
|
|
11
|
+
vite: {
|
|
12
|
+
server: {
|
|
13
|
+
allowedHosts: ['.plt.local']
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nuxt",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "nuxt dev --host 127.0.0.1 --port 0",
|
|
8
|
+
"build": "nuxt build",
|
|
9
|
+
"start": "node .output/server/index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@platformatic/nuxt": "^3.52.4",
|
|
13
|
+
"nuxt": "^4.4.8",
|
|
14
|
+
"vue": "^3.5.22"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/2.0.0.json",
|
|
3
|
+
"entrypoint": "composer",
|
|
4
|
+
"services": [
|
|
5
|
+
{
|
|
6
|
+
"id": "frontend",
|
|
7
|
+
"config": "platformatic.application.json",
|
|
8
|
+
"path": "./services/frontend"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "backend",
|
|
12
|
+
"config": "platformatic.json",
|
|
13
|
+
"path": "./services/backend"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "composer",
|
|
17
|
+
"config": "platformatic.json",
|
|
18
|
+
"path": "./services/composer"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"logger": {
|
|
22
|
+
"level": "error"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineNuxtConfig } from 'nuxt/config'
|
|
2
|
+
|
|
3
|
+
export default defineNuxtConfig({
|
|
4
|
+
ssr: false,
|
|
5
|
+
app: {
|
|
6
|
+
baseURL: '/frontend/'
|
|
7
|
+
},
|
|
8
|
+
compatibilityDate: '2026-06-15',
|
|
9
|
+
telemetry: false,
|
|
10
|
+
devtools: { enabled: false },
|
|
11
|
+
vite: {
|
|
12
|
+
server: {
|
|
13
|
+
allowedHosts: ['.plt.local']
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/2.0.0.json",
|
|
3
|
+
"entrypoint": "composer",
|
|
4
|
+
"services": [
|
|
5
|
+
{
|
|
6
|
+
"id": "frontend",
|
|
7
|
+
"config": "platformatic.application.json",
|
|
8
|
+
"path": "./services/frontend"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "backend",
|
|
12
|
+
"config": "platformatic.json",
|
|
13
|
+
"path": "./services/backend"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "composer",
|
|
17
|
+
"config": "platformatic.json",
|
|
18
|
+
"path": "./services/composer"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"logger": {
|
|
22
|
+
"level": "error"
|
|
23
|
+
}
|
|
24
|
+
}
|