@opengis/fastify-table 1.4.40 → 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
|
@@ -60,7 +60,7 @@ export default async function uploadMultiPart(req, { subdir, originalFilename =
|
|
|
60
60
|
|
|
61
61
|
const value = part?.fields?.file || part;
|
|
62
62
|
|
|
63
|
-
if (!value?.file || !value?.filename) {
|
|
63
|
+
if (!value?.file?.on || !value?.filename) {
|
|
64
64
|
throw new Error('upload error');
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -73,9 +73,9 @@ export default async function uploadMultiPart(req, { subdir, originalFilename =
|
|
|
73
73
|
|
|
74
74
|
const buffer = await new Promise((res, rej) => {
|
|
75
75
|
const chunks = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
value.file.on('data', chunk => chunks.push(chunk));
|
|
77
|
+
value.file.on('end', () => res(Buffer.concat(chunks)));
|
|
78
|
+
value.file.on('error', rej);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
if (!buffer?.length) {
|
|
@@ -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) || {};
|