@opengis/fastify-table 1.4.57 → 1.4.59
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
CHANGED
|
@@ -4,6 +4,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
|
|
6
6
|
import fp from 'fastify-plugin';
|
|
7
|
+
import proxy from '@fastify/http-proxy';
|
|
7
8
|
|
|
8
9
|
import config from './config.js';
|
|
9
10
|
|
|
@@ -114,6 +115,18 @@ async function plugin(fastify, opt) {
|
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
config.proxy?.forEach?.(el => {
|
|
119
|
+
fastify.register(proxy, {
|
|
120
|
+
upstream: el.target,
|
|
121
|
+
prefix: el.source,
|
|
122
|
+
http2: false,
|
|
123
|
+
preHandler: async (req) => {
|
|
124
|
+
req.headers.uid = req.session?.passport?.user?.uid;
|
|
125
|
+
Object.keys(el.headers || {})?.forEach(item => req.headers[item] = el.headers[item]);
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
117
130
|
if (config.dblist) {
|
|
118
131
|
dblistRoutes(fastify, opt);
|
|
119
132
|
}
|
package/package.json
CHANGED
|
@@ -10,13 +10,13 @@ function checkField(key, val, options, idx, body) {
|
|
|
10
10
|
// validators: [required]
|
|
11
11
|
if (type === 'switcher') {
|
|
12
12
|
// skip nulls at non-required switchers, restrict invalid values
|
|
13
|
-
if (val && typeof val !== 'boolean') {
|
|
13
|
+
if (val && typeof val !== 'boolean' && !['true', 'false'].includes(val)) {
|
|
14
14
|
return {
|
|
15
15
|
error: 'not a boolean', key, idx,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
// restrict nulls at required switchers
|
|
19
|
-
if (isrequired && typeof val !== 'boolean') {
|
|
19
|
+
if (isrequired && typeof val !== 'boolean' && !['true', 'false'].includes(val)) {
|
|
20
20
|
return {
|
|
21
21
|
error: 'empty required', key, idx,
|
|
22
22
|
};
|