@opengis/fastify-table 1.4.36 → 1.4.37
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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import dotenv from 'dotenv';
|
|
1
|
+
// import dotenv from 'dotenv';
|
|
2
2
|
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
|
|
@@ -20,7 +20,8 @@ Object.assign(config, {
|
|
|
20
20
|
|
|
21
21
|
function loadEnvConfig() {
|
|
22
22
|
// node --env-file-if-exists=.env.dev --env-file-if-exists=.env server
|
|
23
|
-
|
|
23
|
+
if (config.trace) { console.log(Object.keys(process.env)); }
|
|
24
|
+
const configKeys = Object.keys(process.env).filter(key => !key.startsWith('npm_') && !skipKeys.includes(key) && (key.charAt(0) === key.charAt(0)?.toLowerCase?.() || key.includes('.'))).reduce((acc, curr) => ({ ...acc, [curr]: process.env[curr] }), {});
|
|
24
25
|
Object.assign(config, unflattenObject(configKeys));
|
|
25
26
|
}
|
|
26
27
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import routeData from '../../../routes/table/controllers/tableData.js';
|
|
2
2
|
|
|
3
3
|
export default async function getData({
|
|
4
|
-
id, table, pg, headers, filter, state, limit, page, search, user, order, sql, contextQuery, sufix,
|
|
4
|
+
id, table, pg, headers, filter, state, limit, page, search, user, order, desc, sql, contextQuery, sufix,
|
|
5
5
|
}, reply, called) {
|
|
6
6
|
const params = { table, id };
|
|
7
7
|
const query = {
|
|
8
|
-
filter, limit, page, search, sql, state, order,
|
|
8
|
+
filter, limit, page, search, sql, state, order, desc,
|
|
9
9
|
};
|
|
10
10
|
const result = await routeData({
|
|
11
11
|
pg, headers, params, query, user, contextQuery, sufix,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
2
|
export default function unflattenObject(flatObj) {
|
|
3
|
-
return Object.keys(flatObj).reduce((acc, key) => {
|
|
3
|
+
return Object.keys(flatObj || {}).reduce((acc, key) => {
|
|
4
4
|
const keys = key.split('.');
|
|
5
5
|
keys.reduce((nestedObj, part, index) => {
|
|
6
6
|
if (index === keys.length - 1) {
|
|
@@ -65,6 +65,11 @@ export default async function update(req, reply) {
|
|
|
65
65
|
Object.keys(body || {}).filter(key => !Object.keys(schema || {}).includes(key)).forEach(key => delete body[key]);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
if (tokenData?.obj) {
|
|
69
|
+
const objData = tokenData.obj?.split('#').reduce((p, el) => ({ ...p, [el.split('=')[0]]: el.split('=')[1] }), {}) || {};
|
|
70
|
+
Object.assign(body, objData);
|
|
71
|
+
}
|
|
72
|
+
|
|
68
73
|
const xssCheck = checkXSS({ body, schema });
|
|
69
74
|
|
|
70
75
|
if (xssCheck.error && formData?.xssCheck !== false) {
|
|
@@ -73,7 +73,9 @@ export default async function dataAPI(req, reply, called) {
|
|
|
73
73
|
|
|
74
74
|
if (!config.pg) { return reply.status(500).send('empty pg'); }
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
const pkey = pg.pk?.[params?.table] || pg.pk?.[params?.table.replace(/"/g, '')];
|
|
77
|
+
|
|
78
|
+
if (!loadTable && !(tokenData?.table && pg.pk?.[tokenData?.table]) && !(called && pkey)) {
|
|
77
79
|
return reply.status(404).send('template not found');
|
|
78
80
|
}
|
|
79
81
|
|