@platformatic/composer 2.69.0 → 2.70.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/config.d.ts CHANGED
@@ -506,7 +506,7 @@ export interface PlatformaticComposer {
506
506
  maxELU?: number | string;
507
507
  maxHeapUsed?: number | string;
508
508
  maxHeapTotal?: number | string;
509
- maxYoungGeneration?: number;
509
+ maxYoungGeneration?: number | string;
510
510
  };
511
511
  undici?: {
512
512
  agentOptions?: {
@@ -696,6 +696,7 @@ export interface PlatformaticComposer {
696
696
  [k: string]: unknown;
697
697
  };
698
698
  serviceTimeout?: number | string;
699
+ messagingTimeout?: number | string;
699
700
  env?: {
700
701
  [k: string]: string;
701
702
  };
package/lib/proxy.js CHANGED
@@ -45,7 +45,7 @@ async function resolveServiceProxyParameters (service) {
45
45
  prefix,
46
46
  rewritePrefix,
47
47
  internalRewriteLocationHeader,
48
- needsRootRedirect: meta.needsRootRedirect,
48
+ needsRootTrailingSlash: meta.needsRootTrailingSlash,
49
49
  needsRefererBasedRedirect: meta.needsRefererBasedRedirect,
50
50
  upstream: service.proxy?.upstream,
51
51
  ws: service.proxy?.ws
@@ -72,7 +72,7 @@ module.exports = fp(async function (app, opts) {
72
72
  url,
73
73
  rewritePrefix,
74
74
  internalRewriteLocationHeader,
75
- needsRootRedirect,
75
+ needsRootTrailingSlash,
76
76
  needsRefererBasedRedirect,
77
77
  ws
78
78
  } = parameters
@@ -81,33 +81,15 @@ module.exports = fp(async function (app, opts) {
81
81
  const basePath = `/${prefix ?? ''}`.replaceAll(/\/+/g, '/').replace(/\/$/, '')
82
82
  const dispatcher = getGlobalDispatcher()
83
83
 
84
- if (needsRootRedirect) {
85
- app.addHook('preHandler', (req, reply, done) => {
86
- if (req.url === basePath) {
87
- app.inject(
88
- {
89
- method: req.method,
90
- url: `${basePath}/`,
91
- headers: req.headers,
92
- payload: req.body
93
- },
94
- (err, result) => {
95
- if (err) {
96
- done(err)
97
- return
98
- }
99
-
100
- const replyHeaders = result.headers
101
- delete replyHeaders['content-length']
102
- delete replyHeaders['transfer-encoding']
103
-
104
- reply.code(result.statusCode).headers(replyHeaders).send(result.rawPayload)
105
- done()
106
- }
107
- )
108
- } else {
84
+ if (needsRootTrailingSlash) {
85
+ app.addHook('preHandler', function rootTrailingSlashPreHandler (req, reply, done) {
86
+ if (req.url !== basePath) {
109
87
  done()
88
+ return
110
89
  }
90
+
91
+ const { url, options } = reply.fromParameters(req.url + '/', req.params, prefix)
92
+ reply.from(url.replace(/\/+$/, '/'), options)
111
93
  })
112
94
  }
113
95
 
@@ -118,7 +100,7 @@ module.exports = fp(async function (app, opts) {
118
100
  from the Referer header.
119
101
  */
120
102
  if (needsRefererBasedRedirect) {
121
- app.addHook('preHandler', (req, reply, done) => {
103
+ app.addHook('preHandler', function refererBasedRedirectPreHandler (req, reply, done) {
122
104
  // If the URL is already targeted to the service, do nothing
123
105
  if (req.url.startsWith(basePath)) {
124
106
  done()
@@ -164,11 +146,11 @@ module.exports = fp(async function (app, opts) {
164
146
  : null
165
147
 
166
148
  const proxyOptions = {
167
- websocket: true,
168
149
  prefix,
169
150
  rewritePrefix,
170
151
  upstream: service.proxy?.upstream ?? origin,
171
152
 
153
+ websocket: true,
172
154
  wsUpstream: ws?.upstream ?? url ?? origin,
173
155
  wsReconnect: ws?.reconnect,
174
156
  wsHooks: {
@@ -185,6 +167,7 @@ module.exports = fp(async function (app, opts) {
185
167
  config: {
186
168
  [kProxyRoute]: true
187
169
  },
170
+
188
171
  internalRewriteLocationHeader: false,
189
172
  replyOptions: {
190
173
  rewriteHeaders: headers => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/composer",
3
- "version": "2.69.0",
3
+ "version": "2.70.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -32,20 +32,20 @@
32
32
  "typescript": "^5.5.4",
33
33
  "why-is-node-running": "2",
34
34
  "ws": "^8.16.0",
35
- "@platformatic/client": "2.69.0",
36
- "@platformatic/config": "2.69.0",
37
- "@platformatic/db": "2.69.0"
35
+ "@platformatic/config": "2.70.1",
36
+ "@platformatic/client": "2.70.1",
37
+ "@platformatic/db": "2.70.1"
38
38
  },
39
39
  "dependencies": {
40
40
  "@fastify/error": "^4.0.0",
41
- "@fastify/http-proxy": "^11.1.1",
41
+ "@fastify/http-proxy": "^11.2.0",
42
42
  "@fastify/reply-from": "^12.0.0",
43
43
  "@fastify/static": "^8.0.0",
44
44
  "@fastify/swagger": "^9.0.0",
45
45
  "@fastify/view": "^10.0.1",
46
46
  "@platformatic/fastify-openapi-glue": "^5.1.0",
47
47
  "@platformatic/graphql-composer": "^0.10.0",
48
- "@scalar/fastify-api-reference": "1.31.2",
48
+ "@scalar/fastify-api-reference": "1.31.14",
49
49
  "ajv": "^8.12.0",
50
50
  "commist": "^3.2.0",
51
51
  "console-table-printer": "^2.12.0",
@@ -68,15 +68,15 @@
68
68
  "rfdc": "^1.3.1",
69
69
  "semgrator": "^0.3.0",
70
70
  "undici": "^7.0.0",
71
- "@platformatic/generators": "2.69.0",
72
- "@platformatic/scalar-theme": "2.69.0",
73
- "@platformatic/config": "2.69.0",
74
- "@platformatic/utils": "^2.69.0",
75
- "@platformatic/service": "2.69.0",
76
- "@platformatic/telemetry": "2.69.0"
71
+ "@platformatic/config": "2.70.1",
72
+ "@platformatic/scalar-theme": "2.70.1",
73
+ "@platformatic/service": "2.70.1",
74
+ "@platformatic/telemetry": "2.70.1",
75
+ "@platformatic/generators": "2.70.1",
76
+ "@platformatic/utils": "^2.70.1"
77
77
  },
78
78
  "scripts": {
79
- "test": "pnpm run lint && borp -T --timeout=300000 -c 1 && tsd",
79
+ "test": "pnpm run lint && borp -T --timeout=1200000 -c 1 && tsd",
80
80
  "gen-schema": "node lib/schema.js > schema.json",
81
81
  "gen-types": "json2ts > config.d.ts < schema.json",
82
82
  "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/composer/2.69.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/composer/2.70.1.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Composer",
5
5
  "type": "object",
@@ -1749,7 +1749,6 @@
1749
1749
  "default": {},
1750
1750
  "properties": {
1751
1751
  "enabled": {
1752
- "default": true,
1753
1752
  "anyOf": [
1754
1753
  {
1755
1754
  "type": "boolean"
@@ -1757,10 +1756,10 @@
1757
1756
  {
1758
1757
  "type": "string"
1759
1758
  }
1760
- ]
1759
+ ],
1760
+ "default": true
1761
1761
  },
1762
1762
  "interval": {
1763
- "default": 30000,
1764
1763
  "anyOf": [
1765
1764
  {
1766
1765
  "type": "number",
@@ -1769,10 +1768,10 @@
1769
1768
  {
1770
1769
  "type": "string"
1771
1770
  }
1772
- ]
1771
+ ],
1772
+ "default": 30000
1773
1773
  },
1774
1774
  "gracePeriod": {
1775
- "default": 30000,
1776
1775
  "anyOf": [
1777
1776
  {
1778
1777
  "type": "number",
@@ -1781,10 +1780,10 @@
1781
1780
  {
1782
1781
  "type": "string"
1783
1782
  }
1784
- ]
1783
+ ],
1784
+ "default": 30000
1785
1785
  },
1786
1786
  "maxUnhealthyChecks": {
1787
- "default": 10,
1788
1787
  "anyOf": [
1789
1788
  {
1790
1789
  "type": "number",
@@ -1793,10 +1792,10 @@
1793
1792
  {
1794
1793
  "type": "string"
1795
1794
  }
1796
- ]
1795
+ ],
1796
+ "default": 10
1797
1797
  },
1798
1798
  "maxELU": {
1799
- "default": 0.99,
1800
1799
  "anyOf": [
1801
1800
  {
1802
1801
  "type": "number",
@@ -1806,10 +1805,10 @@
1806
1805
  {
1807
1806
  "type": "string"
1808
1807
  }
1809
- ]
1808
+ ],
1809
+ "default": 0.99
1810
1810
  },
1811
1811
  "maxHeapUsed": {
1812
- "default": 0.99,
1813
1812
  "anyOf": [
1814
1813
  {
1815
1814
  "type": "number",
@@ -1819,10 +1818,10 @@
1819
1818
  {
1820
1819
  "type": "string"
1821
1820
  }
1822
- ]
1821
+ ],
1822
+ "default": 0.99
1823
1823
  },
1824
1824
  "maxHeapTotal": {
1825
- "default": 4294967296,
1826
1825
  "anyOf": [
1827
1826
  {
1828
1827
  "type": "number",
@@ -1831,11 +1830,19 @@
1831
1830
  {
1832
1831
  "type": "string"
1833
1832
  }
1834
- ]
1833
+ ],
1834
+ "default": 4294967296
1835
1835
  },
1836
1836
  "maxYoungGeneration": {
1837
- "type": "number",
1838
- "minimum": 0
1837
+ "anyOf": [
1838
+ {
1839
+ "type": "number",
1840
+ "minimum": 0
1841
+ },
1842
+ {
1843
+ "type": "string"
1844
+ }
1845
+ ]
1839
1846
  }
1840
1847
  },
1841
1848
  "additionalProperties": false
@@ -2310,6 +2317,18 @@
2310
2317
  ],
2311
2318
  "default": 300000
2312
2319
  },
2320
+ "messagingTimeout": {
2321
+ "anyOf": [
2322
+ {
2323
+ "type": "number",
2324
+ "minimum": 1
2325
+ },
2326
+ {
2327
+ "type": "string"
2328
+ }
2329
+ ],
2330
+ "default": 30000
2331
+ },
2313
2332
  "env": {
2314
2333
  "type": "object",
2315
2334
  "additionalProperties": {