@platformatic/composer 2.70.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
@@ -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.70.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/db": "2.70.0",
36
- "@platformatic/client": "2.70.0",
37
- "@platformatic/config": "2.70.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.8",
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/config": "2.70.0",
72
- "@platformatic/generators": "2.70.0",
73
- "@platformatic/scalar-theme": "2.70.0",
74
- "@platformatic/service": "2.70.0",
75
- "@platformatic/telemetry": "2.70.0",
76
- "@platformatic/utils": "^2.70.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.70.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",
@@ -2317,6 +2317,18 @@
2317
2317
  ],
2318
2318
  "default": 300000
2319
2319
  },
2320
+ "messagingTimeout": {
2321
+ "anyOf": [
2322
+ {
2323
+ "type": "number",
2324
+ "minimum": 1
2325
+ },
2326
+ {
2327
+ "type": "string"
2328
+ }
2329
+ ],
2330
+ "default": 30000
2331
+ },
2320
2332
  "env": {
2321
2333
  "type": "object",
2322
2334
  "additionalProperties": {