@platformatic/node 2.0.0-alpha.6 → 2.0.0-alpha.8
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/config.d.ts +14 -0
- package/index.js +160 -37
- package/lib/schema.js +21 -6
- package/package.json +10 -9
- package/schema.json +54 -1
- package/test/express.test.js +0 -54
- package/test/fastify.test.js +0 -54
- package/test/fixtures/express/no-build/index.js +0 -16
- package/test/fixtures/express/no-build/package.json +0 -7
- package/test/fixtures/express/no-build/platformatic.application.json +0 -3
- package/test/fixtures/express/no-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/express/no-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/express/with-build/index.js +0 -17
- package/test/fixtures/express/with-build/package.json +0 -7
- package/test/fixtures/express/with-build/platformatic.application.json +0 -3
- package/test/fixtures/express/with-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/express/with-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/fastify/no-build/index.js +0 -14
- package/test/fixtures/fastify/no-build/package.json +0 -7
- package/test/fixtures/fastify/no-build/platformatic.application.json +0 -3
- package/test/fixtures/fastify/no-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/fastify/no-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/fastify/with-build/index.js +0 -15
- package/test/fixtures/fastify/with-build/package.json +0 -7
- package/test/fixtures/fastify/with-build/platformatic.application.json +0 -3
- package/test/fixtures/fastify/with-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/fastify/with-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/nodejs/no-build/index.js +0 -21
- package/test/fixtures/nodejs/no-build/package.json +0 -7
- package/test/fixtures/nodejs/no-build/platformatic.application.json +0 -3
- package/test/fixtures/nodejs/no-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/nodejs/no-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/nodejs/no-configuration/index.js +0 -21
- package/test/fixtures/nodejs/no-configuration/platformatic.as-entrypoint.runtime.json +0 -18
- package/test/fixtures/nodejs/no-configuration/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/nodejs/with-build/index.js +0 -20
- package/test/fixtures/nodejs/with-build/package.json +0 -7
- package/test/fixtures/nodejs/with-build/platformatic.application.json +0 -3
- package/test/fixtures/nodejs/with-build/platformatic.as-entrypoint.runtime.json +0 -19
- package/test/fixtures/nodejs/with-build/platformatic.no-entrypoint.runtime.json +0 -16
- package/test/fixtures/platformatic-service/platformatic.service.json +0 -15
- package/test/fixtures/platformatic-service/plugin.js +0 -12
- package/test/node.test.js +0 -97
package/config.d.ts
CHANGED
|
@@ -150,4 +150,18 @@ export interface PlatformaticNodeJsStackable {
|
|
|
150
150
|
}
|
|
151
151
|
| boolean
|
|
152
152
|
| string;
|
|
153
|
+
application?: {
|
|
154
|
+
basePath?: string;
|
|
155
|
+
outputDirectory?: string;
|
|
156
|
+
include?: string[];
|
|
157
|
+
commands?: {
|
|
158
|
+
install?: string;
|
|
159
|
+
build?: string;
|
|
160
|
+
development?: string;
|
|
161
|
+
production?: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
node?: {
|
|
165
|
+
entrypoint?: string;
|
|
166
|
+
};
|
|
153
167
|
}
|
package/index.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseStackable,
|
|
3
|
+
cleanBasePath,
|
|
4
|
+
createServerListener,
|
|
5
|
+
ensureTrailingSlash,
|
|
6
|
+
getServerUrl,
|
|
7
|
+
importFile,
|
|
8
|
+
injectViaRequest,
|
|
9
|
+
schemaOptions,
|
|
10
|
+
transformConfig
|
|
11
|
+
} from '@platformatic/basic'
|
|
2
12
|
import { ConfigManager } from '@platformatic/config'
|
|
3
13
|
import inject from 'light-my-request'
|
|
4
14
|
import { existsSync } from 'node:fs'
|
|
5
15
|
import { readFile } from 'node:fs/promises'
|
|
6
16
|
import { Server } from 'node:http'
|
|
7
17
|
import { resolve as pathResolve, resolve } from 'node:path'
|
|
18
|
+
import { pathToFileURL } from 'url'
|
|
8
19
|
import { packageJson, schema } from './lib/schema.js'
|
|
9
20
|
|
|
10
21
|
const validFields = [
|
|
@@ -18,7 +29,7 @@ const validFields = [
|
|
|
18
29
|
'exports#.#node',
|
|
19
30
|
'exports#.#import',
|
|
20
31
|
'exports#.#require',
|
|
21
|
-
'exports#.#default'
|
|
32
|
+
'exports#.#default'
|
|
22
33
|
]
|
|
23
34
|
|
|
24
35
|
const validFilesBasenames = ['index', 'main', 'app', 'application', 'server', 'start', 'bundle', 'run', 'entrypoint']
|
|
@@ -29,18 +40,14 @@ function isFastify (app) {
|
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
export class NodeStackable extends BaseStackable {
|
|
32
|
-
#entrypoint
|
|
33
|
-
#hadEntrypointField
|
|
34
43
|
#module
|
|
35
44
|
#app
|
|
36
45
|
#server
|
|
37
46
|
#dispatcher
|
|
38
47
|
#isFastify
|
|
39
48
|
|
|
40
|
-
constructor (options, root, configManager
|
|
49
|
+
constructor (options, root, configManager) {
|
|
41
50
|
super('nodejs', packageJson.version, options, root, configManager)
|
|
42
|
-
this.#entrypoint = entrypoint
|
|
43
|
-
this.#hadEntrypointField = hadEntrypointField
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
async start ({ listen }) {
|
|
@@ -55,17 +62,36 @@ export class NodeStackable extends BaseStackable {
|
|
|
55
62
|
return this.url
|
|
56
63
|
}
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
65
|
+
const config = this.configManager.current
|
|
66
|
+
const command = config.application.commands[this.isProduction ? 'production' : 'development']
|
|
67
|
+
|
|
68
|
+
if (command) {
|
|
69
|
+
return this.startWithCommand(command)
|
|
63
70
|
}
|
|
64
71
|
|
|
72
|
+
// Resolve the entrypoint
|
|
73
|
+
// The priority is platformatic.application.json, then package.json and finally autodetect.
|
|
74
|
+
// Only when autodetecting we eventually search in the dist folder when in production mode
|
|
75
|
+
const finalEntrypoint = await this._findEntrypoint()
|
|
76
|
+
|
|
77
|
+
// Require the application
|
|
78
|
+
const basePath = config.application?.basePath
|
|
79
|
+
? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
|
|
80
|
+
: undefined
|
|
81
|
+
|
|
82
|
+
this.registerGlobals({
|
|
83
|
+
// Always use URL to avoid serialization problem in Windows
|
|
84
|
+
id: this.id,
|
|
85
|
+
root: pathToFileURL(this.root).toString(),
|
|
86
|
+
basePath,
|
|
87
|
+
logLevel: this.logger.level
|
|
88
|
+
})
|
|
89
|
+
|
|
65
90
|
// The server promise must be created before requiring the entrypoint even if it's not going to be used
|
|
66
91
|
// at all. Otherwise there is chance we miss the listen event.
|
|
67
|
-
const
|
|
68
|
-
|
|
92
|
+
const serverOptions = this.serverConfig
|
|
93
|
+
const serverPromise = createServerListener((this.isEntrypoint ? serverOptions?.port : undefined) ?? true)
|
|
94
|
+
this.#module = await importFile(finalEntrypoint)
|
|
69
95
|
this.#module = this.#module.default || this.#module
|
|
70
96
|
|
|
71
97
|
// Deal with application
|
|
@@ -92,37 +118,60 @@ export class NodeStackable extends BaseStackable {
|
|
|
92
118
|
}
|
|
93
119
|
|
|
94
120
|
async stop () {
|
|
121
|
+
if (this.subprocess) {
|
|
122
|
+
return this.stopCommand()
|
|
123
|
+
}
|
|
124
|
+
|
|
95
125
|
if (this.#isFastify) {
|
|
96
126
|
return this.#app.close()
|
|
97
127
|
}
|
|
98
128
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
129
|
+
/* c8 ignore next 3 */
|
|
130
|
+
if (!this.#server?.listening) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
104
133
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
this.#server.close(error => {
|
|
136
|
+
/* c8 ignore next 3 */
|
|
137
|
+
if (error) {
|
|
138
|
+
return reject(error)
|
|
139
|
+
}
|
|
111
140
|
|
|
112
|
-
|
|
113
|
-
})
|
|
141
|
+
resolve()
|
|
114
142
|
})
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async build () {
|
|
147
|
+
const command = this.configManager.current.application.commands.build
|
|
148
|
+
|
|
149
|
+
if (command) {
|
|
150
|
+
return this.buildWithCommand(command, null)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// If no command was specified, we try to see if there is a build script defined in package.json.
|
|
154
|
+
const hasBuildScript = await this.#hasBuildScript()
|
|
155
|
+
|
|
156
|
+
if (!hasBuildScript) {
|
|
157
|
+
this.logger.warn(
|
|
158
|
+
'No "application.commands.build" configuration value specified and no build script found in package.json. Skipping build ...'
|
|
159
|
+
)
|
|
160
|
+
return
|
|
115
161
|
}
|
|
162
|
+
|
|
163
|
+
return this.buildWithCommand('npm run build', null)
|
|
116
164
|
}
|
|
117
165
|
|
|
118
166
|
async inject (injectParams, onInject) {
|
|
119
167
|
let res
|
|
120
|
-
|
|
168
|
+
|
|
169
|
+
if (this.url) {
|
|
170
|
+
res = await injectViaRequest(this.url, injectParams, onInject)
|
|
171
|
+
} else if (this.#isFastify) {
|
|
121
172
|
res = await this.#app.inject(injectParams, onInject)
|
|
122
|
-
} else if (this.#dispatcher) {
|
|
123
|
-
res = await inject(this.#dispatcher, injectParams, onInject)
|
|
124
173
|
} else {
|
|
125
|
-
res = await
|
|
174
|
+
res = await inject(this.#dispatcher ?? this.#app, injectParams, onInject)
|
|
126
175
|
}
|
|
127
176
|
|
|
128
177
|
/* c8 ignore next 3 */
|
|
@@ -136,6 +185,25 @@ export class NodeStackable extends BaseStackable {
|
|
|
136
185
|
return { statusCode, headers, body, payload, rawPayload }
|
|
137
186
|
}
|
|
138
187
|
|
|
188
|
+
getMeta () {
|
|
189
|
+
const config = this.configManager.current
|
|
190
|
+
let composer = { prefix: this.servicePrefix, wantsAbsoluteUrls: true, needsRootRedirect: true }
|
|
191
|
+
|
|
192
|
+
if (this.url) {
|
|
193
|
+
composer = {
|
|
194
|
+
tcp: true,
|
|
195
|
+
url: this.url,
|
|
196
|
+
prefix: config.application?.basePath
|
|
197
|
+
? ensureTrailingSlash(cleanBasePath(config.application?.basePath))
|
|
198
|
+
: this.servicePrefix,
|
|
199
|
+
wantsAbsoluteUrls: true,
|
|
200
|
+
needsRootRedirect: true
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return { composer }
|
|
205
|
+
}
|
|
206
|
+
|
|
139
207
|
async _listen () {
|
|
140
208
|
const serverOptions = this.serverConfig
|
|
141
209
|
|
|
@@ -161,6 +229,58 @@ export class NodeStackable extends BaseStackable {
|
|
|
161
229
|
_getApplication () {
|
|
162
230
|
return this.#app
|
|
163
231
|
}
|
|
232
|
+
|
|
233
|
+
async _findEntrypoint () {
|
|
234
|
+
const config = this.configManager.current
|
|
235
|
+
const outputRoot = resolve(this.root, config.application.outputDirectory)
|
|
236
|
+
|
|
237
|
+
if (config.node.entrypoint) {
|
|
238
|
+
return pathResolve(this.root, config.node.entrypoint)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const { entrypoint, hadEntrypointField } = await getEntrypointInformation(this.root)
|
|
242
|
+
|
|
243
|
+
if (!entrypoint) {
|
|
244
|
+
this.logger.error(
|
|
245
|
+
`The service ${this.id} had no valid entrypoint defined in the package.json file and no valid entrypoint file was found.`
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
process.exit(1)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (!hadEntrypointField) {
|
|
252
|
+
this.logger.warn(
|
|
253
|
+
`The service ${this.id} had no valid entrypoint defined in the package.json file. Falling back to the file "${entrypoint}".`
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
let root = this.root
|
|
258
|
+
|
|
259
|
+
if (this.isProduction) {
|
|
260
|
+
const hasCommand = this.configManager.current.application.commands.build
|
|
261
|
+
const hasBuildScript = await this.#hasBuildScript()
|
|
262
|
+
|
|
263
|
+
if (hasCommand || hasBuildScript) {
|
|
264
|
+
this.verifyOutputDirectory(outputRoot)
|
|
265
|
+
root = outputRoot
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return pathResolve(root, entrypoint)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async #hasBuildScript () {
|
|
273
|
+
// If no command was specified, we try to see if there is a build script defined in package.json.
|
|
274
|
+
let hasBuildScript
|
|
275
|
+
try {
|
|
276
|
+
const packageJson = JSON.parse(await readFile(resolve(this.root, 'package.json'), 'utf-8'))
|
|
277
|
+
hasBuildScript = typeof packageJson.scripts.build === 'string' && packageJson.scripts.build
|
|
278
|
+
} catch (e) {
|
|
279
|
+
// No-op
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return hasBuildScript
|
|
283
|
+
}
|
|
164
284
|
}
|
|
165
285
|
|
|
166
286
|
async function getEntrypointInformation (root) {
|
|
@@ -213,18 +333,21 @@ async function getEntrypointInformation (root) {
|
|
|
213
333
|
export async function buildStackable (opts) {
|
|
214
334
|
const root = opts.context.directory
|
|
215
335
|
|
|
216
|
-
const {
|
|
217
|
-
|
|
218
|
-
const configManager = new ConfigManager({ schema, source: opts.config ?? {} })
|
|
336
|
+
const configManager = new ConfigManager({ schema, source: opts.config ?? {}, schemaOptions, transformConfig })
|
|
219
337
|
await configManager.parseAndValidate()
|
|
220
338
|
|
|
221
|
-
return new NodeStackable(opts, root, configManager
|
|
339
|
+
return new NodeStackable(opts, root, configManager)
|
|
222
340
|
}
|
|
223
341
|
|
|
342
|
+
export { schema, schemaComponents } from './lib/schema.js'
|
|
343
|
+
|
|
224
344
|
export default {
|
|
225
345
|
configType: 'nodejs',
|
|
226
|
-
configManagerConfig: {
|
|
346
|
+
configManagerConfig: {
|
|
347
|
+
schemaOptions,
|
|
348
|
+
transformConfig
|
|
349
|
+
},
|
|
227
350
|
buildStackable,
|
|
228
351
|
schema,
|
|
229
|
-
version: packageJson.version
|
|
352
|
+
version: packageJson.version
|
|
230
353
|
}
|
package/lib/schema.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { schemaComponents } from '@platformatic/basic'
|
|
2
|
-
import {
|
|
1
|
+
import { schemaComponents as basicSchemaComponents } from '@platformatic/basic'
|
|
2
|
+
import { schemaComponents as utilsSchemaComponents } from '@platformatic/utils'
|
|
3
3
|
import { readFileSync } from 'node:fs'
|
|
4
4
|
|
|
5
5
|
export const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'))
|
|
6
6
|
|
|
7
|
+
const node = {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
entrypoint: {
|
|
11
|
+
type: 'string'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
default: {},
|
|
15
|
+
additionalProperties: false
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const schemaComponents = { node }
|
|
19
|
+
|
|
7
20
|
export const schema = {
|
|
8
21
|
$id: `https://schemas.platformatic.dev/@platformatic/vite/${packageJson.version}.json`,
|
|
9
22
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
@@ -11,12 +24,14 @@ export const schema = {
|
|
|
11
24
|
type: 'object',
|
|
12
25
|
properties: {
|
|
13
26
|
$schema: {
|
|
14
|
-
type: 'string'
|
|
27
|
+
type: 'string'
|
|
15
28
|
},
|
|
16
|
-
server:
|
|
17
|
-
watch:
|
|
29
|
+
server: utilsSchemaComponents.server,
|
|
30
|
+
watch: basicSchemaComponents.watch,
|
|
31
|
+
application: basicSchemaComponents.application,
|
|
32
|
+
node
|
|
18
33
|
},
|
|
19
|
-
additionalProperties: false
|
|
34
|
+
additionalProperties: false
|
|
20
35
|
}
|
|
21
36
|
|
|
22
37
|
/* c8 ignore next 3 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/node",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.8",
|
|
4
4
|
"description": "Platformatic Node.js Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"light-my-request": "^
|
|
19
|
-
"@platformatic/basic": "2.0.0-alpha.
|
|
20
|
-
"@platformatic/
|
|
21
|
-
"@platformatic/
|
|
18
|
+
"light-my-request": "^6.0.0",
|
|
19
|
+
"@platformatic/basic": "2.0.0-alpha.8",
|
|
20
|
+
"@platformatic/config": "2.0.0-alpha.8",
|
|
21
|
+
"@platformatic/utils": "2.0.0-alpha.8"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"borp": "^0.17.0",
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
"fastify": "^4.28.1",
|
|
28
28
|
"json-schema-to-typescript": "^15.0.1",
|
|
29
29
|
"neostandard": "^0.11.1",
|
|
30
|
+
"tsx": "^4.19.0",
|
|
30
31
|
"typescript": "^5.5.4",
|
|
31
|
-
"@platformatic/
|
|
32
|
-
"@platformatic/
|
|
32
|
+
"@platformatic/service": "2.0.0-alpha.8",
|
|
33
|
+
"@platformatic/composer": "2.0.0-alpha.8"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
|
-
"test": "npm run lint && borp --concurrency=1 --timeout
|
|
36
|
-
"coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout
|
|
36
|
+
"test": "npm run lint && borp --concurrency=1 --no-timeout",
|
|
37
|
+
"coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --no-timeout",
|
|
37
38
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
38
39
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
39
40
|
"build": "pnpm run gen-schema && pnpm run gen-types",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/vite/2.0.0-alpha.8.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Node.js Stackable",
|
|
5
5
|
"type": "object",
|
|
@@ -491,6 +491,59 @@
|
|
|
491
491
|
"type": "string"
|
|
492
492
|
}
|
|
493
493
|
]
|
|
494
|
+
},
|
|
495
|
+
"application": {
|
|
496
|
+
"type": "object",
|
|
497
|
+
"properties": {
|
|
498
|
+
"basePath": {
|
|
499
|
+
"type": "string"
|
|
500
|
+
},
|
|
501
|
+
"outputDirectory": {
|
|
502
|
+
"type": "string",
|
|
503
|
+
"default": "dist"
|
|
504
|
+
},
|
|
505
|
+
"include": {
|
|
506
|
+
"type": "array",
|
|
507
|
+
"items": {
|
|
508
|
+
"type": "string"
|
|
509
|
+
},
|
|
510
|
+
"default": [
|
|
511
|
+
"dist"
|
|
512
|
+
]
|
|
513
|
+
},
|
|
514
|
+
"commands": {
|
|
515
|
+
"type": "object",
|
|
516
|
+
"properties": {
|
|
517
|
+
"install": {
|
|
518
|
+
"type": "string",
|
|
519
|
+
"default": "npm ci --omit-dev"
|
|
520
|
+
},
|
|
521
|
+
"build": {
|
|
522
|
+
"type": "string"
|
|
523
|
+
},
|
|
524
|
+
"development": {
|
|
525
|
+
"type": "string"
|
|
526
|
+
},
|
|
527
|
+
"production": {
|
|
528
|
+
"type": "string"
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
"default": {},
|
|
532
|
+
"additionalProperties": false
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
"additionalProperties": false,
|
|
536
|
+
"default": {}
|
|
537
|
+
},
|
|
538
|
+
"node": {
|
|
539
|
+
"type": "object",
|
|
540
|
+
"properties": {
|
|
541
|
+
"entrypoint": {
|
|
542
|
+
"type": "string"
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
"default": {},
|
|
546
|
+
"additionalProperties": false
|
|
494
547
|
}
|
|
495
548
|
},
|
|
496
549
|
"additionalProperties": false
|
package/test/express.test.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ifError } from 'node:assert'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
|
-
import { test } from 'node:test'
|
|
4
|
-
import { createRuntime, setFixturesDir, verifyJSONViaHTTP, verifyJSONViaInject } from '../../basic/test/helper.js'
|
|
5
|
-
|
|
6
|
-
const packageRoot = resolve(import.meta.dirname, '..')
|
|
7
|
-
setFixturesDir(resolve(import.meta.dirname, './fixtures'))
|
|
8
|
-
|
|
9
|
-
test('can detect and start an express application with no build function defined', async t => {
|
|
10
|
-
const { runtime, url } = await createRuntime(
|
|
11
|
-
t,
|
|
12
|
-
'express/no-build/platformatic.as-entrypoint.runtime.json',
|
|
13
|
-
packageRoot
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
17
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test('can detect and start an express application with no build function and when not the entrypoint', async t => {
|
|
21
|
-
const { runtime, url } = await createRuntime(
|
|
22
|
-
t,
|
|
23
|
-
'express/no-build/platformatic.no-entrypoint.runtime.json',
|
|
24
|
-
packageRoot
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
28
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('can detect and start an express application with build function defined', async t => {
|
|
32
|
-
const { runtime, url } = await createRuntime(
|
|
33
|
-
t,
|
|
34
|
-
'express/with-build/platformatic.as-entrypoint.runtime.json',
|
|
35
|
-
packageRoot
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
39
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('can detect and start an express applicationwith build function defined and when not the entrypoint', async t => {
|
|
43
|
-
const { runtime, url } = await createRuntime(
|
|
44
|
-
t,
|
|
45
|
-
'express/no-build/platformatic.no-entrypoint.runtime.json',
|
|
46
|
-
packageRoot
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
50
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
51
|
-
|
|
52
|
-
const details = await runtime.getServiceDetails('internal')
|
|
53
|
-
ifError(details.url)
|
|
54
|
-
})
|
package/test/fastify.test.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ifError } from 'node:assert'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
|
-
import { test } from 'node:test'
|
|
4
|
-
import { createRuntime, setFixturesDir, verifyJSONViaHTTP, verifyJSONViaInject } from '../../basic/test/helper.js'
|
|
5
|
-
|
|
6
|
-
const packageRoot = resolve(import.meta.dirname, '..')
|
|
7
|
-
setFixturesDir(resolve(import.meta.dirname, './fixtures'))
|
|
8
|
-
|
|
9
|
-
test('can detect and start a fastify application with no build function defined', async t => {
|
|
10
|
-
const { runtime, url } = await createRuntime(
|
|
11
|
-
t,
|
|
12
|
-
'fastify/no-build/platformatic.as-entrypoint.runtime.json',
|
|
13
|
-
packageRoot
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
17
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test('can detect and start a fastify application with no build function and when not the entrypoint', async t => {
|
|
21
|
-
const { runtime, url } = await createRuntime(
|
|
22
|
-
t,
|
|
23
|
-
'fastify/no-build/platformatic.no-entrypoint.runtime.json',
|
|
24
|
-
packageRoot
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
28
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('can detect and start a fastify application with build function defined', async t => {
|
|
32
|
-
const { runtime, url } = await createRuntime(
|
|
33
|
-
t,
|
|
34
|
-
'fastify/with-build/platformatic.as-entrypoint.runtime.json',
|
|
35
|
-
packageRoot
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
39
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('can detect and start a fastify application with build function defined and when not the entrypoint', async t => {
|
|
43
|
-
const { runtime, url } = await createRuntime(
|
|
44
|
-
t,
|
|
45
|
-
'fastify/no-build/platformatic.no-entrypoint.runtime.json',
|
|
46
|
-
packageRoot
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
50
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
51
|
-
|
|
52
|
-
const details = await runtime.getServiceDetails('internal')
|
|
53
|
-
ifError(details.url)
|
|
54
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import express from 'express'
|
|
2
|
-
|
|
3
|
-
const app = express()
|
|
4
|
-
|
|
5
|
-
app.get('/direct', (req, res) => {
|
|
6
|
-
res.send({ ok: true })
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
app.get('/internal', (req, res) => {
|
|
10
|
-
fetch('http://main.plt.local/direct')
|
|
11
|
-
.then(response => response.json())
|
|
12
|
-
.then(res.json.bind(res))
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
// This would likely fail if our code doesn't work
|
|
16
|
-
app.listen(1)
|
|
@@ -1,19 +0,0 @@
|
|
|
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": "main",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
{ "id": "main", "path": "../../platformatic-service", "config": "platformatic.service.json" },
|
|
14
|
-
{ "id": "internal", "path": ".", "config": "platformatic.application.json" }
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import express from 'express'
|
|
2
|
-
|
|
3
|
-
export function build () {
|
|
4
|
-
const app = express()
|
|
5
|
-
|
|
6
|
-
app.get('/direct', (req, res) => {
|
|
7
|
-
res.send({ ok: true })
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
app.get('/internal', (req, res) => {
|
|
11
|
-
fetch('http://main.plt.local/direct')
|
|
12
|
-
.then(response => response.json())
|
|
13
|
-
.then(res.json.bind(res))
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
return app
|
|
17
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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": "main",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
{ "id": "main", "path": "../../platformatic-service", "config": "platformatic.service.json" },
|
|
14
|
-
{ "id": "internal", "path": ".", "config": "platformatic.application.json" }
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import fastify from 'fastify'
|
|
2
|
-
|
|
3
|
-
const app = fastify()
|
|
4
|
-
|
|
5
|
-
app.get('/direct', async () => {
|
|
6
|
-
return { ok: true }
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
app.get('/internal', () => {
|
|
10
|
-
return fetch('http://main.plt.local/direct').then(response => response.json())
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
// This would likely fail if our code doesn't work
|
|
14
|
-
app.listen({ port: 1 })
|
|
@@ -1,19 +0,0 @@
|
|
|
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": "main",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
{ "id": "main", "path": "../../platformatic-service", "config": "platformatic.service.json" },
|
|
14
|
-
{ "id": "internal", "path": ".", "config": "platformatic.application.json" }
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fastify from 'fastify'
|
|
2
|
-
|
|
3
|
-
export function build () {
|
|
4
|
-
const app = fastify()
|
|
5
|
-
|
|
6
|
-
app.get('/direct', async () => {
|
|
7
|
-
return { ok: true }
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
app.get('/internal', () => {
|
|
11
|
-
return fetch('http://main.plt.local/direct').then(response => response.json())
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
return app
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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": "main",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
{ "id": "main", "path": "../../platformatic-service", "config": "platformatic.service.json" },
|
|
14
|
-
{ "id": "internal", "path": ".", "config": "platformatic.application.json" }
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createServer } from 'node:http'
|
|
2
|
-
|
|
3
|
-
const server = createServer((req, res) => {
|
|
4
|
-
if (req.url === '/direct') {
|
|
5
|
-
res.writeHead(200, { 'content-type': 'application/json', connection: 'close' })
|
|
6
|
-
res.end(JSON.stringify({ ok: true }))
|
|
7
|
-
} else if (req.url === '/mesh') {
|
|
8
|
-
fetch('http://main.plt.local/direct')
|
|
9
|
-
.then(response => response.json())
|
|
10
|
-
.then(json => {
|
|
11
|
-
res.writeHead(200, { 'content-type': 'application/json', connection: 'close' })
|
|
12
|
-
res.end(JSON.stringify({ ok: true }))
|
|
13
|
-
})
|
|
14
|
-
} else {
|
|
15
|
-
res.writeHead(404, { 'content-type': 'application/json', connection: 'close' })
|
|
16
|
-
res.end(JSON.stringify({ ok: false }))
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
// This would likely fail if our code doesn't work
|
|
21
|
-
server.listen(1)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": true,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "warn"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{
|
|
14
|
-
"id": "main",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": true,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "warn"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{ "id": "main", "path": "../../platformatic-service", "config": "platformatic.service.json" },
|
|
14
|
-
{ "id": "internal", "path": ".", "config": "platformatic.application.json" }
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createServer } from 'node:http'
|
|
2
|
-
|
|
3
|
-
const server = createServer((req, res) => {
|
|
4
|
-
if (req.url === '/direct') {
|
|
5
|
-
res.writeHead(200, { 'content-type': 'application/json', connection: 'close' })
|
|
6
|
-
res.end(JSON.stringify({ ok: true }))
|
|
7
|
-
} else if (req.url === '/mesh') {
|
|
8
|
-
fetch('http://main.plt.local/direct')
|
|
9
|
-
.then(response => response.json())
|
|
10
|
-
.then(json => {
|
|
11
|
-
res.writeHead(200, { 'content-type': 'application/json', connection: 'close' })
|
|
12
|
-
res.end(JSON.stringify({ ok: true }))
|
|
13
|
-
})
|
|
14
|
-
} else {
|
|
15
|
-
res.writeHead(404, { 'content-type': 'application/json', connection: 'close' })
|
|
16
|
-
res.end(JSON.stringify({ ok: false }))
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
// This would likely fail if our code doesn't work
|
|
21
|
-
server.listen(1)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": true,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "warn"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{
|
|
14
|
-
"id": "main",
|
|
15
|
-
"path": "."
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": true,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "warn"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{ "id": "main", "path": "../../platformatic-service", "config": "platformatic.service.json" },
|
|
14
|
-
{ "id": "internal", "path": "." }
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createServer } from 'node:http'
|
|
2
|
-
|
|
3
|
-
export function build () {
|
|
4
|
-
return createServer((req, res) => {
|
|
5
|
-
if (req.url === '/direct') {
|
|
6
|
-
res.writeHead(200, { 'content-type': 'application/json', connection: 'close' })
|
|
7
|
-
res.end(JSON.stringify({ ok: true }))
|
|
8
|
-
} else if (req.url === '/mesh') {
|
|
9
|
-
fetch('http://main.plt.local/direct')
|
|
10
|
-
.then(response => response.json())
|
|
11
|
-
.then(json => {
|
|
12
|
-
res.writeHead(200, { 'content-type': 'application/json', connection: 'close' })
|
|
13
|
-
res.end(JSON.stringify({ ok: true }))
|
|
14
|
-
})
|
|
15
|
-
} else {
|
|
16
|
-
res.writeHead(404, { 'content-type': 'application/json', connection: 'close' })
|
|
17
|
-
res.end(JSON.stringify({ ok: false }))
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": true,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "warn"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{
|
|
14
|
-
"id": "main",
|
|
15
|
-
"path": ".",
|
|
16
|
-
"config": "platformatic.application.json"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
|
|
3
|
-
"entrypoint": "main",
|
|
4
|
-
"watch": false,
|
|
5
|
-
"managementApi": true,
|
|
6
|
-
"metrics": false,
|
|
7
|
-
"server": {
|
|
8
|
-
"logger": {
|
|
9
|
-
"level": "warn"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"services": [
|
|
13
|
-
{ "id": "main", "path": "../../platformatic-service", "config": "platformatic.service.json" },
|
|
14
|
-
{ "id": "internal", "path": ".", "config": "platformatic.application.json" }
|
|
15
|
-
]
|
|
16
|
-
}
|
package/test/node.test.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { deepStrictEqual, ifError, ok } from 'node:assert'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
3
|
-
import { test } from 'node:test'
|
|
4
|
-
import {
|
|
5
|
-
createRuntime,
|
|
6
|
-
getLogs,
|
|
7
|
-
setFixturesDir,
|
|
8
|
-
verifyJSONViaHTTP,
|
|
9
|
-
verifyJSONViaInject
|
|
10
|
-
} from '../../basic/test/helper.js'
|
|
11
|
-
|
|
12
|
-
const packageRoot = resolve(import.meta.dirname, '..')
|
|
13
|
-
setFixturesDir(resolve(import.meta.dirname, './fixtures'))
|
|
14
|
-
|
|
15
|
-
test('can detect and start a Node.js application with no configuration files', async t => {
|
|
16
|
-
const { runtime, url } = await createRuntime(
|
|
17
|
-
t,
|
|
18
|
-
'nodejs/no-configuration/platformatic.as-entrypoint.runtime.json',
|
|
19
|
-
packageRoot
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
23
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
24
|
-
|
|
25
|
-
const missingConfigurationMessage =
|
|
26
|
-
'The service main had no valid entrypoint defined in the package.json file. Falling back to the file index.js.'
|
|
27
|
-
|
|
28
|
-
const logs = await getLogs(runtime)
|
|
29
|
-
ok(logs.map(m => m.msg).includes(missingConfigurationMessage))
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('can detect and start a Node.js application with no configuration files and when not the entrypoint', async t => {
|
|
33
|
-
const { runtime, url } = await createRuntime(
|
|
34
|
-
t,
|
|
35
|
-
'nodejs/no-configuration/platformatic.no-entrypoint.runtime.json',
|
|
36
|
-
packageRoot
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
40
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
41
|
-
|
|
42
|
-
const missingConfigurationMessage =
|
|
43
|
-
'The service internal had no valid entrypoint defined in the package.json file. Falling back to the file index.js.'
|
|
44
|
-
|
|
45
|
-
const logs = await getLogs(runtime)
|
|
46
|
-
ok(logs.map(m => m.msg).includes(missingConfigurationMessage))
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('can detect and start a Node.js application with no build function defined', async t => {
|
|
50
|
-
const { runtime, url } = await createRuntime(
|
|
51
|
-
t,
|
|
52
|
-
'nodejs/no-build/platformatic.as-entrypoint.runtime.json',
|
|
53
|
-
packageRoot
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
57
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
58
|
-
|
|
59
|
-
const logs = await getLogs(runtime)
|
|
60
|
-
deepStrictEqual(logs, [])
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('can detect and start a Node.js application with no build function and when not the entrypoint', async t => {
|
|
64
|
-
const { runtime, url } = await createRuntime(
|
|
65
|
-
t,
|
|
66
|
-
'nodejs/no-build/platformatic.no-entrypoint.runtime.json',
|
|
67
|
-
packageRoot
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
71
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test('can detect and start a Node.js application with build function defined', async t => {
|
|
75
|
-
const { runtime, url } = await createRuntime(
|
|
76
|
-
t,
|
|
77
|
-
'nodejs/with-build/platformatic.as-entrypoint.runtime.json',
|
|
78
|
-
packageRoot
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
await verifyJSONViaHTTP(url, '/direct', 200, { ok: true })
|
|
82
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test('can detect and start a Node.js application with build function defined and when not the entrypoint', async t => {
|
|
86
|
-
const { runtime, url } = await createRuntime(
|
|
87
|
-
t,
|
|
88
|
-
'nodejs/no-build/platformatic.no-entrypoint.runtime.json',
|
|
89
|
-
packageRoot
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
await verifyJSONViaHTTP(url, '/mesh', 200, { ok: true })
|
|
93
|
-
await verifyJSONViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
|
|
94
|
-
|
|
95
|
-
const details = await runtime.getServiceDetails('internal')
|
|
96
|
-
ifError(details.url)
|
|
97
|
-
})
|