@platformatic/gateway 3.24.0 → 3.25.0

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
@@ -247,6 +247,9 @@ export interface PlatformaticGatewayConfig {
247
247
  upstream?: string;
248
248
  prefix?: string;
249
249
  hostname?: string;
250
+ custom?: {
251
+ path: string;
252
+ };
250
253
  ws?: {
251
254
  upstream?: string;
252
255
  reconnect?: {
package/lib/proxy.js CHANGED
@@ -35,6 +35,11 @@ async function resolveApplicationProxyParameters (application) {
35
35
  internalRewriteLocationHeader = false
36
36
  }
37
37
 
38
+ if (application.proxy?.custom) {
39
+ const custom = await loadModule(createRequire(import.meta.filename), application.proxy.custom.path)
40
+ application.proxy.custom = custom
41
+ }
42
+
38
43
  if (application.proxy?.ws?.hooks) {
39
44
  const hooks = await loadModule(createRequire(import.meta.filename), application.proxy.ws.hooks.path)
40
45
  application.proxy.ws.hooks = hooks
@@ -152,11 +157,16 @@ async function proxyPlugin (app, opts) {
152
157
  metrics = initMetrics(globalThis.platformatic?.prometheus)
153
158
  }
154
159
 
160
+ const getUpstream = application.proxy?.custom?.getUpstream
161
+ // When getUpstream is provided, upstream ust be undefined, otherwise the getUpstream will be ignored
162
+ const upstream = getUpstream ? undefined : (application.proxy?.upstream ?? origin)
163
+
155
164
  const proxyOptions = {
156
165
  prefix,
157
166
  rewritePrefix,
158
- upstream: application.proxy?.upstream ?? origin,
167
+ upstream,
159
168
  preRewrite,
169
+ preValidation: application.proxy?.custom?.preValidation,
160
170
 
161
171
  websocket: true,
162
172
  wsUpstream: ws?.upstream ?? url ?? origin,
@@ -234,7 +244,8 @@ async function proxyPlugin (app, opts) {
234
244
  onError: (reply, { error }) => {
235
245
  app.log.error({ error: ensureLoggableError(error) }, 'Error while proxying request to another application')
236
246
  return reply.send(error)
237
- }
247
+ },
248
+ getUpstream
238
249
  }
239
250
  }
240
251
 
package/lib/schema.js CHANGED
@@ -139,6 +139,14 @@ export const gateway = {
139
139
  upstream: { type: 'string' },
140
140
  prefix: { type: 'string' },
141
141
  hostname: { type: 'string' },
142
+ custom: {
143
+ type: 'object',
144
+ properties: {
145
+ path: { type: 'string' }
146
+ },
147
+ required: ['path'],
148
+ additionalProperties: false
149
+ },
142
150
  ws: {
143
151
  type: 'object',
144
152
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/gateway",
3
- "version": "3.24.0",
3
+ "version": "3.25.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "typescript": "^5.5.4",
34
34
  "why-is-node-running": "2",
35
35
  "ws": "^8.16.0",
36
- "@platformatic/db": "3.24.0"
36
+ "@platformatic/db": "3.25.0"
37
37
  },
38
38
  "dependencies": {
39
39
  "@fastify/error": "^4.0.0",
@@ -64,11 +64,11 @@
64
64
  "rfdc": "^1.3.1",
65
65
  "semgrator": "^0.3.0",
66
66
  "undici": "^7.0.0",
67
- "@platformatic/basic": "3.24.0",
68
- "@platformatic/foundation": "^3.24.0",
69
- "@platformatic/telemetry": "3.24.0",
70
- "@platformatic/scalar-theme": "3.24.0",
71
- "@platformatic/service": "3.24.0"
67
+ "@platformatic/basic": "3.25.0",
68
+ "@platformatic/foundation": "^3.25.0",
69
+ "@platformatic/service": "3.25.0",
70
+ "@platformatic/telemetry": "3.25.0",
71
+ "@platformatic/scalar-theme": "3.25.0"
72
72
  },
73
73
  "engines": {
74
74
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.24.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.25.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Gateway Config",
5
5
  "type": "object",
@@ -792,6 +792,18 @@
792
792
  "hostname": {
793
793
  "type": "string"
794
794
  },
795
+ "custom": {
796
+ "type": "object",
797
+ "properties": {
798
+ "path": {
799
+ "type": "string"
800
+ }
801
+ },
802
+ "required": [
803
+ "path"
804
+ ],
805
+ "additionalProperties": false
806
+ },
795
807
  "ws": {
796
808
  "type": "object",
797
809
  "properties": {