@opengis/fastify-table 1.4.41 → 1.4.42
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/package.json
CHANGED
|
@@ -34,7 +34,27 @@ async function getPGAsync(param) {
|
|
|
34
34
|
|
|
35
35
|
pgClients[name] = new pg.Pool(dbConfig);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
try {
|
|
38
|
+
await init(pgClients[name]);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.error(
|
|
42
|
+
'pg client init error',
|
|
43
|
+
host,
|
|
44
|
+
port,
|
|
45
|
+
database,
|
|
46
|
+
);
|
|
47
|
+
// debug only
|
|
48
|
+
if (config.local && name !== 'client') {
|
|
49
|
+
console.warn(
|
|
50
|
+
'fall back to default pgClient',
|
|
51
|
+
pgClients.client?.host,
|
|
52
|
+
pgClients.client?.port,
|
|
53
|
+
pgClients.client?.database,
|
|
54
|
+
);
|
|
55
|
+
return pgClients.client;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
38
58
|
|
|
39
59
|
return pgClients[name];
|
|
40
60
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
dataDelete, getTemplate, getAccess, applyHook, getToken, config, pgClients,
|
|
2
|
+
dataDelete, getTemplate, getAccess, applyHook, getToken, config, pgClients, getOpt,
|
|
3
3
|
} from '../../../../utils.js';
|
|
4
4
|
|
|
5
5
|
export default async function deleteCrud(req, reply) {
|
|
6
6
|
const {
|
|
7
|
-
pg = pgClients.client, user, params = {}, headers = {},
|
|
7
|
+
pg = pgClients.client, user = {}, params = {}, headers = {},
|
|
8
8
|
} = req || {};
|
|
9
9
|
|
|
10
10
|
const hookData = await applyHook('preDelete', {
|
|
@@ -18,7 +18,7 @@ export default async function deleteCrud(req, reply) {
|
|
|
18
18
|
const { referer } = headers;
|
|
19
19
|
const tokenData = await getToken({
|
|
20
20
|
uid: user.uid, token: params.id || params.table, json: 1,
|
|
21
|
-
});
|
|
21
|
+
}) || await getOpt(params.id || params.table, user.uid);
|
|
22
22
|
|
|
23
23
|
const { table: del, id } = hookData || tokenData || (config.security?.disableToken || config.local || config.auth?.disable ? req.params : {});
|
|
24
24
|
const { actions = [] } = await getAccess({ table: del, id, user }, pg) || {};
|