@platformatic/gateway 3.24.0 → 3.26.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 +59 -0
- package/lib/proxy.js +13 -2
- package/lib/schema.js +8 -0
- package/package.json +7 -7
- package/schema.json +271 -1
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?: {
|
|
@@ -792,6 +795,62 @@ export interface PlatformaticGatewayConfig {
|
|
|
792
795
|
[k: string]: string | [string, ...string[]];
|
|
793
796
|
};
|
|
794
797
|
};
|
|
798
|
+
application?: {
|
|
799
|
+
reuseTcpPorts?: boolean;
|
|
800
|
+
workers?:
|
|
801
|
+
| number
|
|
802
|
+
| string
|
|
803
|
+
| {
|
|
804
|
+
static?: number;
|
|
805
|
+
minimum?: number;
|
|
806
|
+
maximum?: number;
|
|
807
|
+
[k: string]: unknown;
|
|
808
|
+
};
|
|
809
|
+
health?: {
|
|
810
|
+
enabled?: boolean | string;
|
|
811
|
+
interval?: number | string;
|
|
812
|
+
gracePeriod?: number | string;
|
|
813
|
+
maxUnhealthyChecks?: number | string;
|
|
814
|
+
maxELU?: number | string;
|
|
815
|
+
maxHeapUsed?: number | string;
|
|
816
|
+
maxHeapTotal?: number | string;
|
|
817
|
+
maxYoungGeneration?: number | string;
|
|
818
|
+
codeRangeSize?: number | string;
|
|
819
|
+
};
|
|
820
|
+
arguments?: string[];
|
|
821
|
+
env?: {
|
|
822
|
+
[k: string]: string;
|
|
823
|
+
};
|
|
824
|
+
envfile?: string;
|
|
825
|
+
sourceMaps?: boolean;
|
|
826
|
+
packageManager?: "npm" | "pnpm" | "yarn";
|
|
827
|
+
preload?: string | string[];
|
|
828
|
+
nodeOptions?: string;
|
|
829
|
+
execArgv?: string[];
|
|
830
|
+
permissions?: {
|
|
831
|
+
fs?: {
|
|
832
|
+
read?: string[];
|
|
833
|
+
write?: string[];
|
|
834
|
+
};
|
|
835
|
+
};
|
|
836
|
+
telemetry?: {
|
|
837
|
+
/**
|
|
838
|
+
* An array of instrumentations loaded if telemetry is enabled
|
|
839
|
+
*/
|
|
840
|
+
instrumentations?: (
|
|
841
|
+
| string
|
|
842
|
+
| {
|
|
843
|
+
package: string;
|
|
844
|
+
exportName?: string;
|
|
845
|
+
options?: {
|
|
846
|
+
[k: string]: unknown;
|
|
847
|
+
};
|
|
848
|
+
[k: string]: unknown;
|
|
849
|
+
}
|
|
850
|
+
)[];
|
|
851
|
+
[k: string]: unknown;
|
|
852
|
+
};
|
|
853
|
+
};
|
|
795
854
|
};
|
|
796
855
|
telemetry?: {
|
|
797
856
|
enabled?: boolean | string;
|
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
|
|
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.
|
|
3
|
+
"version": "3.26.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.
|
|
36
|
+
"@platformatic/db": "3.26.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.
|
|
68
|
-
"@platformatic/foundation": "^3.
|
|
69
|
-
"@platformatic/
|
|
70
|
-
"@platformatic/
|
|
71
|
-
"@platformatic/
|
|
67
|
+
"@platformatic/basic": "3.26.0",
|
|
68
|
+
"@platformatic/foundation": "^3.26.0",
|
|
69
|
+
"@platformatic/scalar-theme": "3.26.0",
|
|
70
|
+
"@platformatic/service": "3.26.0",
|
|
71
|
+
"@platformatic/telemetry": "3.26.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.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.26.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": {
|
|
@@ -1505,6 +1517,12 @@
|
|
|
1505
1517
|
"nodeOptions": {
|
|
1506
1518
|
"type": "string"
|
|
1507
1519
|
},
|
|
1520
|
+
"execArgv": {
|
|
1521
|
+
"type": "array",
|
|
1522
|
+
"items": {
|
|
1523
|
+
"type": "string"
|
|
1524
|
+
}
|
|
1525
|
+
},
|
|
1508
1526
|
"permissions": {
|
|
1509
1527
|
"type": "object",
|
|
1510
1528
|
"properties": {
|
|
@@ -2812,6 +2830,258 @@
|
|
|
2812
2830
|
"deny"
|
|
2813
2831
|
],
|
|
2814
2832
|
"additionalProperties": false
|
|
2833
|
+
},
|
|
2834
|
+
"application": {
|
|
2835
|
+
"type": "object",
|
|
2836
|
+
"properties": {
|
|
2837
|
+
"reuseTcpPorts": {
|
|
2838
|
+
"type": "boolean",
|
|
2839
|
+
"default": true
|
|
2840
|
+
},
|
|
2841
|
+
"workers": {
|
|
2842
|
+
"anyOf": [
|
|
2843
|
+
{
|
|
2844
|
+
"type": "number"
|
|
2845
|
+
},
|
|
2846
|
+
{
|
|
2847
|
+
"type": "string"
|
|
2848
|
+
},
|
|
2849
|
+
{
|
|
2850
|
+
"type": "object",
|
|
2851
|
+
"properties": {
|
|
2852
|
+
"static": {
|
|
2853
|
+
"type": "number",
|
|
2854
|
+
"minimum": 1
|
|
2855
|
+
},
|
|
2856
|
+
"minimum": {
|
|
2857
|
+
"type": "number",
|
|
2858
|
+
"minimum": 1
|
|
2859
|
+
},
|
|
2860
|
+
"maximum": {
|
|
2861
|
+
"type": "number",
|
|
2862
|
+
"minimum": 0
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
]
|
|
2867
|
+
},
|
|
2868
|
+
"health": {
|
|
2869
|
+
"type": "object",
|
|
2870
|
+
"default": {},
|
|
2871
|
+
"properties": {
|
|
2872
|
+
"enabled": {
|
|
2873
|
+
"anyOf": [
|
|
2874
|
+
{
|
|
2875
|
+
"type": "boolean"
|
|
2876
|
+
},
|
|
2877
|
+
{
|
|
2878
|
+
"type": "string"
|
|
2879
|
+
}
|
|
2880
|
+
]
|
|
2881
|
+
},
|
|
2882
|
+
"interval": {
|
|
2883
|
+
"anyOf": [
|
|
2884
|
+
{
|
|
2885
|
+
"type": "number",
|
|
2886
|
+
"minimum": 0
|
|
2887
|
+
},
|
|
2888
|
+
{
|
|
2889
|
+
"type": "string"
|
|
2890
|
+
}
|
|
2891
|
+
]
|
|
2892
|
+
},
|
|
2893
|
+
"gracePeriod": {
|
|
2894
|
+
"anyOf": [
|
|
2895
|
+
{
|
|
2896
|
+
"type": "number",
|
|
2897
|
+
"minimum": 0
|
|
2898
|
+
},
|
|
2899
|
+
{
|
|
2900
|
+
"type": "string"
|
|
2901
|
+
}
|
|
2902
|
+
]
|
|
2903
|
+
},
|
|
2904
|
+
"maxUnhealthyChecks": {
|
|
2905
|
+
"anyOf": [
|
|
2906
|
+
{
|
|
2907
|
+
"type": "number",
|
|
2908
|
+
"minimum": 1
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
"type": "string"
|
|
2912
|
+
}
|
|
2913
|
+
]
|
|
2914
|
+
},
|
|
2915
|
+
"maxELU": {
|
|
2916
|
+
"anyOf": [
|
|
2917
|
+
{
|
|
2918
|
+
"type": "number",
|
|
2919
|
+
"minimum": 0,
|
|
2920
|
+
"maximum": 1
|
|
2921
|
+
},
|
|
2922
|
+
{
|
|
2923
|
+
"type": "string"
|
|
2924
|
+
}
|
|
2925
|
+
]
|
|
2926
|
+
},
|
|
2927
|
+
"maxHeapUsed": {
|
|
2928
|
+
"anyOf": [
|
|
2929
|
+
{
|
|
2930
|
+
"type": "number",
|
|
2931
|
+
"minimum": 0,
|
|
2932
|
+
"maximum": 1
|
|
2933
|
+
},
|
|
2934
|
+
{
|
|
2935
|
+
"type": "string"
|
|
2936
|
+
}
|
|
2937
|
+
]
|
|
2938
|
+
},
|
|
2939
|
+
"maxHeapTotal": {
|
|
2940
|
+
"anyOf": [
|
|
2941
|
+
{
|
|
2942
|
+
"type": "number",
|
|
2943
|
+
"minimum": 0
|
|
2944
|
+
},
|
|
2945
|
+
{
|
|
2946
|
+
"type": "string"
|
|
2947
|
+
}
|
|
2948
|
+
]
|
|
2949
|
+
},
|
|
2950
|
+
"maxYoungGeneration": {
|
|
2951
|
+
"anyOf": [
|
|
2952
|
+
{
|
|
2953
|
+
"type": "number",
|
|
2954
|
+
"minimum": 0
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
"type": "string"
|
|
2958
|
+
}
|
|
2959
|
+
]
|
|
2960
|
+
},
|
|
2961
|
+
"codeRangeSize": {
|
|
2962
|
+
"anyOf": [
|
|
2963
|
+
{
|
|
2964
|
+
"type": "number",
|
|
2965
|
+
"minimum": 0
|
|
2966
|
+
},
|
|
2967
|
+
{
|
|
2968
|
+
"type": "string"
|
|
2969
|
+
}
|
|
2970
|
+
]
|
|
2971
|
+
}
|
|
2972
|
+
},
|
|
2973
|
+
"additionalProperties": false
|
|
2974
|
+
},
|
|
2975
|
+
"arguments": {
|
|
2976
|
+
"type": "array",
|
|
2977
|
+
"items": {
|
|
2978
|
+
"type": "string"
|
|
2979
|
+
}
|
|
2980
|
+
},
|
|
2981
|
+
"env": {
|
|
2982
|
+
"type": "object",
|
|
2983
|
+
"additionalProperties": {
|
|
2984
|
+
"type": "string"
|
|
2985
|
+
}
|
|
2986
|
+
},
|
|
2987
|
+
"envfile": {
|
|
2988
|
+
"type": "string"
|
|
2989
|
+
},
|
|
2990
|
+
"sourceMaps": {
|
|
2991
|
+
"type": "boolean"
|
|
2992
|
+
},
|
|
2993
|
+
"packageManager": {
|
|
2994
|
+
"type": "string",
|
|
2995
|
+
"enum": [
|
|
2996
|
+
"npm",
|
|
2997
|
+
"pnpm",
|
|
2998
|
+
"yarn"
|
|
2999
|
+
]
|
|
3000
|
+
},
|
|
3001
|
+
"preload": {
|
|
3002
|
+
"anyOf": [
|
|
3003
|
+
{
|
|
3004
|
+
"type": "string",
|
|
3005
|
+
"resolvePath": true
|
|
3006
|
+
},
|
|
3007
|
+
{
|
|
3008
|
+
"type": "array",
|
|
3009
|
+
"items": {
|
|
3010
|
+
"type": "string",
|
|
3011
|
+
"resolvePath": true
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
]
|
|
3015
|
+
},
|
|
3016
|
+
"nodeOptions": {
|
|
3017
|
+
"type": "string"
|
|
3018
|
+
},
|
|
3019
|
+
"execArgv": {
|
|
3020
|
+
"type": "array",
|
|
3021
|
+
"items": {
|
|
3022
|
+
"type": "string"
|
|
3023
|
+
}
|
|
3024
|
+
},
|
|
3025
|
+
"permissions": {
|
|
3026
|
+
"type": "object",
|
|
3027
|
+
"properties": {
|
|
3028
|
+
"fs": {
|
|
3029
|
+
"type": "object",
|
|
3030
|
+
"properties": {
|
|
3031
|
+
"read": {
|
|
3032
|
+
"type": "array",
|
|
3033
|
+
"items": {
|
|
3034
|
+
"type": "string"
|
|
3035
|
+
}
|
|
3036
|
+
},
|
|
3037
|
+
"write": {
|
|
3038
|
+
"type": "array",
|
|
3039
|
+
"items": {
|
|
3040
|
+
"type": "string"
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
},
|
|
3044
|
+
"additionalProperties": false
|
|
3045
|
+
}
|
|
3046
|
+
},
|
|
3047
|
+
"additionalProperties": false
|
|
3048
|
+
},
|
|
3049
|
+
"telemetry": {
|
|
3050
|
+
"type": "object",
|
|
3051
|
+
"properties": {
|
|
3052
|
+
"instrumentations": {
|
|
3053
|
+
"type": "array",
|
|
3054
|
+
"description": "An array of instrumentations loaded if telemetry is enabled",
|
|
3055
|
+
"items": {
|
|
3056
|
+
"oneOf": [
|
|
3057
|
+
{
|
|
3058
|
+
"type": "string"
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
"type": "object",
|
|
3062
|
+
"properties": {
|
|
3063
|
+
"package": {
|
|
3064
|
+
"type": "string"
|
|
3065
|
+
},
|
|
3066
|
+
"exportName": {
|
|
3067
|
+
"type": "string"
|
|
3068
|
+
},
|
|
3069
|
+
"options": {
|
|
3070
|
+
"type": "object",
|
|
3071
|
+
"additionalProperties": true
|
|
3072
|
+
}
|
|
3073
|
+
},
|
|
3074
|
+
"required": [
|
|
3075
|
+
"package"
|
|
3076
|
+
]
|
|
3077
|
+
}
|
|
3078
|
+
]
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
},
|
|
3084
|
+
"additionalProperties": false
|
|
2815
3085
|
}
|
|
2816
3086
|
},
|
|
2817
3087
|
"additionalProperties": false
|