@platformatic/basic 2.0.0-alpha.3 → 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 (54) hide show
  1. package/NOTICE +13 -0
  2. package/README.md +13 -0
  3. package/config.d.ts +11 -0
  4. package/eslint.config.js +3 -1
  5. package/index.js +63 -77
  6. package/lib/base.js +11 -9
  7. package/lib/errors.js +8 -0
  8. package/lib/schema.js +31 -15
  9. package/lib/utils.js +6 -39
  10. package/lib/worker/child-manager.js +90 -0
  11. package/lib/worker/child-process.js +150 -0
  12. package/lib/worker/server-listener.js +29 -0
  13. package/package.json +18 -11
  14. package/schema.json +12 -0
  15. package/test/helper.js +116 -16
  16. package/lib/server.js +0 -135
  17. package/test/express.test.js +0 -34
  18. package/test/fastify.test.js +0 -34
  19. package/test/fixtures/express/no-build/index.js +0 -16
  20. package/test/fixtures/express/no-build/package.json +0 -7
  21. package/test/fixtures/express/no-build/platformatic.app.json +0 -3
  22. package/test/fixtures/express/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  23. package/test/fixtures/express/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  24. package/test/fixtures/express/with-build/index.js +0 -17
  25. package/test/fixtures/express/with-build/package.json +0 -7
  26. package/test/fixtures/express/with-build/platformatic.app.json +0 -3
  27. package/test/fixtures/express/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  28. package/test/fixtures/express/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  29. package/test/fixtures/fastify/no-build/index.js +0 -14
  30. package/test/fixtures/fastify/no-build/package.json +0 -7
  31. package/test/fixtures/fastify/no-build/platformatic.app.json +0 -3
  32. package/test/fixtures/fastify/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  33. package/test/fixtures/fastify/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  34. package/test/fixtures/fastify/with-build/index.js +0 -15
  35. package/test/fixtures/fastify/with-build/package.json +0 -7
  36. package/test/fixtures/fastify/with-build/platformatic.app.json +0 -3
  37. package/test/fixtures/fastify/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  38. package/test/fixtures/fastify/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  39. package/test/fixtures/nodejs/no-build/index.js +0 -21
  40. package/test/fixtures/nodejs/no-build/package.json +0 -7
  41. package/test/fixtures/nodejs/no-build/platformatic.app.json +0 -3
  42. package/test/fixtures/nodejs/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  43. package/test/fixtures/nodejs/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  44. package/test/fixtures/nodejs/no-configuration/index.js +0 -21
  45. package/test/fixtures/nodejs/no-configuration/platformatic.as-entrypoint.runtime.json +0 -18
  46. package/test/fixtures/nodejs/no-configuration/platformatic.no-entrypoint.runtime.json +0 -16
  47. package/test/fixtures/nodejs/with-build/index.js +0 -20
  48. package/test/fixtures/nodejs/with-build/package.json +0 -7
  49. package/test/fixtures/nodejs/with-build/platformatic.app.json +0 -3
  50. package/test/fixtures/nodejs/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  51. package/test/fixtures/nodejs/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  52. package/test/fixtures/platformatic-service/platformatic.service.json +0 -15
  53. package/test/fixtures/platformatic-service/plugin.js +0 -12
  54. package/test/node.test.js +0 -66
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,27 +15,34 @@
15
15
  },
16
16
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
17
  "dependencies": {
18
- "light-my-request": "^5.13.0",
18
+ "@fastify/error": "^4.0.0",
19
19
  "pino": "^9.3.2",
20
+ "semver": "^7.6.3",
20
21
  "undici": "^6.19.5",
21
- "@platformatic/config": "2.0.0-alpha.3"
22
+ "@platformatic/config": "2.0.0-alpha.5",
23
+ "@platformatic/utils": "2.0.0-alpha.5",
24
+ "@platformatic/itc": "2.0.0-alpha.5"
22
25
  },
23
26
  "devDependencies": {
24
27
  "borp": "^0.17.0",
25
- "express": "^4.19.2",
26
28
  "eslint": "9",
29
+ "express": "^4.19.2",
27
30
  "fastify": "^4.28.1",
31
+ "json-schema-to-typescript": "^15.0.0",
28
32
  "neostandard": "^0.11.1",
33
+ "next": "^14.2.5",
34
+ "react": "^18.3.1",
35
+ "react-dom": "^18.3.1",
29
36
  "typescript": "^5.5.4",
30
- "@platformatic/composer": "2.0.0-alpha.3",
31
- "@platformatic/service": "2.0.0-alpha.3",
32
- "@platformatic/utils": "2.0.0-alpha.3"
37
+ "vite": "^5.4.0",
38
+ "ws": "^8.18.0",
39
+ "@platformatic/composer": "2.0.0-alpha.5",
40
+ "@platformatic/service": "2.0.0-alpha.5"
33
41
  },
34
42
  "scripts": {
35
- "test": "npm run lint && borp --concurrency=1 --timeout=180000",
36
- "coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout=180000",
37
- "lint": "eslint",
38
43
  "gen-schema": "node lib/schema.js > schema.json",
39
- "gen-types": "json2ts > config.d.ts < schema.json"
44
+ "gen-types": "json2ts > config.d.ts < schema.json",
45
+ "build": "pnpm run gen-schema && pnpm run gen-types",
46
+ "lint": "eslint"
40
47
  }
41
48
  }
package/schema.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.5.json",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Platformatic Stackable",
5
+ "type": "object",
6
+ "properties": {
7
+ "$schema": {
8
+ "type": "string"
9
+ }
10
+ },
11
+ "additionalProperties": true
12
+ }
package/test/helper.js CHANGED
@@ -1,14 +1,49 @@
1
- import { deepStrictEqual, strictEqual } from 'node:assert'
2
- import { resolve } from 'node:path'
1
+ import { createDirectory, withResolvers } from '@platformatic/utils'
2
+ import { deepStrictEqual, ok, strictEqual } from 'node:assert'
3
+ import { existsSync } from 'node:fs'
4
+ import { readFile, symlink, writeFile } from 'node:fs/promises'
5
+ import { dirname, resolve } from 'node:path'
3
6
  import { setTimeout as sleep } from 'node:timers/promises'
4
7
  import { Client, request } from 'undici'
8
+ import WebSocket from 'ws'
5
9
  import { loadConfig } from '../../config/index.js'
6
10
  import { buildServer, platformaticRuntime } from '../../runtime/index.js'
7
11
 
8
- export const fixturesDir = resolve(import.meta.dirname, './fixtures')
12
+ export { setTimeout as sleep } from 'node:timers/promises'
9
13
 
10
- export async function createRuntime (t, path) {
14
+ let hrmVersion = Date.now()
15
+ export let fixturesDir
16
+
17
+ export function setFixturesDir (directory) {
18
+ fixturesDir = directory
19
+ }
20
+
21
+ // This is used to debug tests
22
+ export function pause (url, timeout = 300000) {
23
+ console.log(`Server is listening at ${url}`)
24
+ return sleep(timeout)
25
+ }
26
+
27
+ export async function ensureDependency (directory, pkg, source) {
28
+ const [namespace, name] = pkg.includes('/') ? pkg.split('/') : ['', pkg]
29
+ const basedir = resolve(fixturesDir, directory, `node_modules/${namespace}`)
30
+ const destination = resolve(basedir, name)
31
+
32
+ await createDirectory(basedir)
33
+ if (!existsSync(destination)) {
34
+ await symlink(source, destination, 'dir')
35
+ }
36
+ }
37
+
38
+ export async function createRuntime (t, path, packageRoot) {
11
39
  const configFile = resolve(fixturesDir, path)
40
+
41
+ if (packageRoot) {
42
+ const packageName = JSON.parse(await readFile(resolve(packageRoot, 'package.json'), 'utf-8')).name
43
+ const root = dirname(configFile)
44
+ await ensureDependency(root, packageName, packageRoot)
45
+ }
46
+
12
47
  const config = await loadConfig({}, ['-c', configFile], platformaticRuntime)
13
48
  const runtime = await buildServer(config.configManager.current)
14
49
  const url = await runtime.start()
@@ -20,18 +55,6 @@ export async function createRuntime (t, path) {
20
55
  return { runtime, url }
21
56
  }
22
57
 
23
- export async function verifyViaHTTP (baseUrl, path, expectedCode, expectedContent) {
24
- const { statusCode, body } = await request(baseUrl + path)
25
- strictEqual(statusCode, expectedCode)
26
- deepStrictEqual(await body.json(), expectedContent)
27
- }
28
-
29
- export async function verifyViaInject (app, serviceId, method, url, expectedCode, expectedContent) {
30
- const { statusCode, body } = await app.inject(serviceId, { method, url })
31
- strictEqual(statusCode, expectedCode)
32
- deepStrictEqual(JSON.parse(body), expectedContent)
33
- }
34
-
35
58
  export async function getLogs (app) {
36
59
  const client = new Client(
37
60
  {
@@ -63,3 +86,80 @@ export async function getLogs (app) {
63
86
  .filter(l => l)
64
87
  .map(m => JSON.parse(m))
65
88
  }
89
+
90
+ export async function updateHMRVersion (versionFile) {
91
+ versionFile ??= resolve(fixturesDir, '../tmp/version.js')
92
+ await createDirectory(dirname(versionFile))
93
+ await writeFile(versionFile, `export const version = ${hrmVersion++}\n`, 'utf-8')
94
+ }
95
+
96
+ export async function verifyJSONViaHTTP (baseUrl, path, expectedCode, expectedContent) {
97
+ const { statusCode, body } = await request(baseUrl + path)
98
+ strictEqual(statusCode, expectedCode)
99
+ deepStrictEqual(await body.json(), expectedContent)
100
+ }
101
+
102
+ export async function verifyJSONViaInject (app, serviceId, method, url, expectedCode, expectedContent) {
103
+ const { statusCode, body } = await app.inject(serviceId, { method, url })
104
+ strictEqual(statusCode, expectedCode)
105
+ deepStrictEqual(JSON.parse(body), expectedContent)
106
+ }
107
+
108
+ export async function verifyHTMLViaHTTP (baseUrl, path, contents) {
109
+ const { statusCode, headers, body } = await request(baseUrl + path, { maxRedirections: 1 })
110
+ const html = await body.text()
111
+
112
+ deepStrictEqual(statusCode, 200)
113
+ ok(headers['content-type']?.startsWith('text/html'))
114
+
115
+ for (const content of contents) {
116
+ ok(content instanceof RegExp ? content.test(html) : html.includes(content))
117
+ }
118
+ }
119
+
120
+ export async function verifyHTMLViaInject (app, serviceId, url, contents) {
121
+ const { statusCode, headers, body: html } = await app.inject(serviceId, { method: 'GET', url })
122
+
123
+ deepStrictEqual(statusCode, 200)
124
+ ok(headers['content-type'].startsWith('text/html'))
125
+
126
+ for (const content of contents) {
127
+ ok(content instanceof RegExp ? content.test(html) : html.includes(content))
128
+ }
129
+ }
130
+
131
+ export async function verifyHMR (baseUrl, path, protocol, handler) {
132
+ const connection = withResolvers()
133
+ const reload = withResolvers()
134
+ const ac = new AbortController()
135
+ const timeout = sleep(10000, 'timeout', { signal: ac.signal })
136
+
137
+ const url = baseUrl.replace('http:', 'ws:') + path
138
+ const webSocket = new WebSocket(url, protocol)
139
+
140
+ webSocket.on('error', err => {
141
+ clearTimeout(timeout)
142
+ connection.reject(err)
143
+ reload.reject(err)
144
+ })
145
+
146
+ webSocket.on('message', data => {
147
+ handler(JSON.parse(data), connection.resolve, reload.resolve)
148
+ })
149
+
150
+ try {
151
+ if ((await Promise.race([connection.promise, timeout])) === 'timeout') {
152
+ throw new Error('Timeout while waiting for HMR connection')
153
+ }
154
+
155
+ await sleep(1000)
156
+ await updateHMRVersion()
157
+
158
+ if ((await Promise.race([reload.promise, timeout])) === 'timeout') {
159
+ throw new Error('Timeout while waiting for HMR reload')
160
+ }
161
+ } finally {
162
+ webSocket.terminate()
163
+ ac.abort()
164
+ }
165
+ }
package/lib/server.js DELETED
@@ -1,135 +0,0 @@
1
- import inject from 'light-my-request'
2
- import { Server } from 'node:http'
3
- import { join } from 'node:path'
4
- import { pathToFileURL } from 'node:url'
5
- import { BaseStackable } from './base.js'
6
- import { createPortManager, getServerUrl, injectViaRequest, isFastify } from './utils.js'
7
-
8
- export class ServerStackable extends BaseStackable {
9
- #entrypoint
10
- #hadEntrypointField
11
- #module
12
- #app
13
- #server
14
- #dispatcher
15
- #isFastify
16
-
17
- constructor (options, root, configManager, entrypoint, hadEntrypointField) {
18
- super(options, root, configManager)
19
- this.#entrypoint = entrypoint
20
- this.#hadEntrypointField = hadEntrypointField
21
- }
22
-
23
- async start ({ listen }) {
24
- // Make this idempotent
25
- if (this.url) {
26
- return this.url
27
- }
28
-
29
- // Listen if entrypoint
30
- if (this.#app && listen) {
31
- await this.#listen()
32
- return this.url
33
- }
34
-
35
- // Require the application
36
- if (!this.#hadEntrypointField) {
37
- this.logger.warn(
38
- `The service ${this.id} had no valid entrypoint defined in the package.json file. Falling back to the file ${this.#entrypoint}.`
39
- )
40
- }
41
-
42
- // The port manager must be created before requiring the entrypoint even if it's not going to be used
43
- // at all. Otherwise there is chance we miss the listen event.
44
- const portManager = createPortManager()
45
- this.#module = await import(pathToFileURL(join(this.root, this.#entrypoint)))
46
- this.#module = this.#module.default || this.#module
47
-
48
- // Deal with application
49
- if (typeof this.#module.build === 'function') {
50
- // We have build function, this Stackable will not use HTTP unless it is the entrypoint
51
- portManager.destroy()
52
-
53
- this.#app = await this.#module.build()
54
- this.#isFastify = isFastify(this.#app)
55
-
56
- if (this.#isFastify) {
57
- await this.#app.ready()
58
- } else if (this.#app instanceof Server) {
59
- this.#server = this.#app
60
- this.#dispatcher = this.#server.listeners('request')[0]
61
- }
62
- } else {
63
- // User blackbox function, we wait for it to listen on a port
64
- this.#server = await portManager.getServer()
65
- this.url = getServerUrl(this.#server)
66
- portManager.destroy()
67
- }
68
-
69
- return this.url
70
- }
71
-
72
- async stop () {
73
- if (this.#isFastify) {
74
- return this.#app.close()
75
- }
76
-
77
- if (this.#server) {
78
- if (!this.#server.listening) {
79
- return
80
- }
81
-
82
- return new Promise((resolve, reject) => {
83
- this.#server.close(error => {
84
- if (error) {
85
- return reject(error)
86
- }
87
-
88
- resolve(error)
89
- })
90
- })
91
- }
92
- }
93
-
94
- async inject (injectParams, onInject) {
95
- let res
96
- if (this.#isFastify) {
97
- res = await this.#app.inject(injectParams, onInject)
98
- } else if (this.#dispatcher) {
99
- res = await inject(this.#dispatcher, injectParams, onInject)
100
- } else {
101
- res = await injectViaRequest(this.url, injectParams, onInject)
102
- }
103
-
104
- if (onInject) {
105
- return
106
- }
107
-
108
- // Since inject might be called from the main thread directly via ITC, let's clean it up
109
- const { statusCode, headers, body, payload, rawPayload } = res
110
-
111
- return { statusCode, headers, body, payload, rawPayload }
112
- }
113
-
114
- async #listen () {
115
- const serverOptions = this.serverConfig
116
-
117
- if (this.#isFastify) {
118
- await this.#app.listen({ host: serverOptions?.hostname || '127.0.0.1', port: serverOptions?.port || 0 })
119
- this.url = getServerUrl(this.#app.server)
120
- } else {
121
- // Express / Node
122
- this.#server = await new Promise((resolve, reject) => {
123
- return this.#app
124
- .listen({ host: serverOptions?.hostname || '127.0.0.1', port: serverOptions?.port || 0 }, function () {
125
- resolve(this)
126
- })
127
- .on('error', reject)
128
- })
129
-
130
- this.url = getServerUrl(this.#server)
131
- }
132
-
133
- return this.url
134
- }
135
- }
@@ -1,34 +0,0 @@
1
- import { ifError } from 'node:assert'
2
- import { test } from 'node:test'
3
- import { createRuntime, verifyViaHTTP, verifyViaInject } from './helper.js'
4
-
5
- test('can detect and start an express application with no build function defined', async t => {
6
- const { runtime, url } = await createRuntime(t, 'express/no-build/platformatic.as-entrypoint.runtime.json')
7
-
8
- await verifyViaHTTP(url, '/direct', 200, { ok: true })
9
- await verifyViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
10
- })
11
-
12
- test('can detect and start an express application with no build function and when not the entrypoint', async t => {
13
- const { runtime, url } = await createRuntime(t, 'express/no-build/platformatic.no-entrypoint.runtime.json')
14
-
15
- await verifyViaHTTP(url, '/mesh', 200, { ok: true })
16
- await verifyViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
17
- })
18
-
19
- test('can detect and start an express application with build function defined', async t => {
20
- const { runtime, url } = await createRuntime(t, 'express/with-build/platformatic.as-entrypoint.runtime.json')
21
-
22
- await verifyViaHTTP(url, '/direct', 200, { ok: true })
23
- await verifyViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
24
- })
25
-
26
- test('can detect and start an express applicationwith build function defined and when not the entrypoint', async t => {
27
- const { runtime, url } = await createRuntime(t, 'express/no-build/platformatic.no-entrypoint.runtime.json')
28
-
29
- await verifyViaHTTP(url, '/mesh', 200, { ok: true })
30
- await verifyViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
31
-
32
- const details = await runtime.getServiceDetails('internal')
33
- ifError(details.url)
34
- })
@@ -1,34 +0,0 @@
1
- import { ifError } from 'node:assert'
2
- import { test } from 'node:test'
3
- import { createRuntime, verifyViaHTTP, verifyViaInject } from './helper.js'
4
-
5
- test('can detect and start a fastify application with no build function defined', async t => {
6
- const { runtime, url } = await createRuntime(t, 'fastify/no-build/platformatic.as-entrypoint.runtime.json')
7
-
8
- await verifyViaHTTP(url, '/direct', 200, { ok: true })
9
- await verifyViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
10
- })
11
-
12
- test('can detect and start a fastify application with no build function and when not the entrypoint', async t => {
13
- const { runtime, url } = await createRuntime(t, 'fastify/no-build/platformatic.no-entrypoint.runtime.json')
14
-
15
- await verifyViaHTTP(url, '/mesh', 200, { ok: true })
16
- await verifyViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
17
- })
18
-
19
- test('can detect and start a fastify application with build function defined', async t => {
20
- const { runtime, url } = await createRuntime(t, 'fastify/with-build/platformatic.as-entrypoint.runtime.json')
21
-
22
- await verifyViaHTTP(url, '/direct', 200, { ok: true })
23
- await verifyViaInject(runtime, 'main', 'GET', '/direct', 200, { ok: true })
24
- })
25
-
26
- test('can detect and start a fastify application with build function defined and when not the entrypoint', async t => {
27
- const { runtime, url } = await createRuntime(t, 'fastify/no-build/platformatic.no-entrypoint.runtime.json')
28
-
29
- await verifyViaHTTP(url, '/mesh', 200, { ok: true })
30
- await verifyViaInject(runtime, 'main', 'GET', '/mesh', 200, { ok: true })
31
-
32
- const details = await runtime.getServiceDetails('internal')
33
- ifError(details.url)
34
- })
@@ -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,7 +0,0 @@
1
- {
2
- "main": "index.js",
3
- "type": "module",
4
- "dependencies": {
5
- "express": "^4.19.2"
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/basic/1.52.0.json"
3
- }
@@ -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.app.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.app.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,7 +0,0 @@
1
- {
2
- "main": "index.js",
3
- "type": "module",
4
- "dependencies": {
5
- "express": "^4.19.2"
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/basic/1.52.0.json"
3
- }
@@ -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.app.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.app.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,7 +0,0 @@
1
- {
2
- "main": "index.js",
3
- "type": "module",
4
- "dependencies": {
5
- "fastify": "^4.28.1"
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/basic/1.52.0.json"
3
- }
@@ -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.app.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.app.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,7 +0,0 @@
1
- {
2
- "main": "index.js",
3
- "type": "module",
4
- "dependencies": {
5
- "fastify": "^4.28.1"
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/basic/1.52.0.json"
3
- }