@platformatic/node 2.0.0-alpha.24 → 2.0.0-alpha.26
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/index.js +10 -1
- package/package.json +8 -7
- package/schema.json +1 -1
package/index.js
CHANGED
|
@@ -40,12 +40,17 @@ function isFastify (app) {
|
|
|
40
40
|
return Object.getOwnPropertySymbols(app).some(s => s.description === 'fastify.state')
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function isKoa (app) {
|
|
44
|
+
return typeof app.callback === 'function'
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
export class NodeStackable extends BaseStackable {
|
|
44
48
|
#module
|
|
45
49
|
#app
|
|
46
50
|
#server
|
|
47
51
|
#dispatcher
|
|
48
52
|
#isFastify
|
|
53
|
+
#isKoa
|
|
49
54
|
|
|
50
55
|
constructor (options, root, configManager) {
|
|
51
56
|
super('nodejs', packageJson.version, options, root, configManager)
|
|
@@ -102,15 +107,19 @@ export class NodeStackable extends BaseStackable {
|
|
|
102
107
|
|
|
103
108
|
// Deal with application
|
|
104
109
|
const factory = ['build', 'create'].find(f => typeof this.#module[f] === 'function')
|
|
110
|
+
|
|
105
111
|
if (factory) {
|
|
106
112
|
// We have build function, this Stackable will not use HTTP unless it is the entrypoint
|
|
107
113
|
serverPromise.cancel()
|
|
108
114
|
|
|
109
115
|
this.#app = await this.#module[factory]()
|
|
110
116
|
this.#isFastify = isFastify(this.#app)
|
|
117
|
+
this.#isKoa = isKoa(this.#app)
|
|
111
118
|
|
|
112
119
|
if (this.#isFastify) {
|
|
113
120
|
await this.#app.ready()
|
|
121
|
+
} else if (this.#isKoa) {
|
|
122
|
+
this.#dispatcher = this.#app.callback()
|
|
114
123
|
} else if (this.#app instanceof Server) {
|
|
115
124
|
this.#server = this.#app
|
|
116
125
|
this.#dispatcher = this.#server.listeners('request')[0]
|
|
@@ -230,7 +239,7 @@ export class NodeStackable extends BaseStackable {
|
|
|
230
239
|
await this.#app.listen({ host: serverOptions?.hostname || '127.0.0.1', port: serverOptions?.port || 0 })
|
|
231
240
|
this.url = getServerUrl(this.#app.server)
|
|
232
241
|
} else {
|
|
233
|
-
// Express / Node
|
|
242
|
+
// Express / Node / Koa
|
|
234
243
|
this.#server = await new Promise((resolve, reject) => {
|
|
235
244
|
return this.#app
|
|
236
245
|
.listen({ host: serverOptions?.hostname || '127.0.0.1', port: serverOptions?.port || 0 }, function () {
|
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.26",
|
|
4
4
|
"description": "Platformatic Node.js Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"light-my-request": "^6.0.0",
|
|
19
|
-
"@platformatic/
|
|
20
|
-
"@platformatic/
|
|
21
|
-
"@platformatic/utils": "2.0.0-alpha.
|
|
22
|
-
"@platformatic/telemetry": "2.0.0-alpha.
|
|
19
|
+
"@platformatic/basic": "2.0.0-alpha.26",
|
|
20
|
+
"@platformatic/config": "2.0.0-alpha.26",
|
|
21
|
+
"@platformatic/utils": "2.0.0-alpha.26",
|
|
22
|
+
"@platformatic/telemetry": "2.0.0-alpha.26"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"borp": "^0.17.0",
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"eslint": "9",
|
|
28
28
|
"fastify": "^5.0.0",
|
|
29
29
|
"json-schema-to-typescript": "^15.0.1",
|
|
30
|
+
"koa": "^2.15.3",
|
|
30
31
|
"neostandard": "^0.11.1",
|
|
31
32
|
"tsx": "^4.19.0",
|
|
32
33
|
"typescript": "^5.5.4",
|
|
33
|
-
"@platformatic/composer": "2.0.0-alpha.
|
|
34
|
-
"@platformatic/service": "2.0.0-alpha.
|
|
34
|
+
"@platformatic/composer": "2.0.0-alpha.26",
|
|
35
|
+
"@platformatic/service": "2.0.0-alpha.26"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"test": "npm run lint && borp --concurrency=1 --no-timeout",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/node/2.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/node/2.0.0-alpha.26.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Node.js Stackable",
|
|
5
5
|
"type": "object",
|