@opengis/fastify-table 2.0.60 → 2.0.63
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/server/plugins/auth/funcs/authorizeUser.js +2 -2
- package/dist/server/plugins/file/uploadMultiPart.d.ts.map +1 -1
- package/dist/server/plugins/file/uploadMultiPart.js +5 -4
- package/dist/server/plugins/logger/errorMessage.d.ts.map +1 -1
- package/dist/server/plugins/logger/errorMessage.js +3 -0
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA6aA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA6aA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QA6a3B;;AACD,wBAA0B"}
|
package/dist/index.js
CHANGED
|
@@ -453,6 +453,9 @@ function plugin(fastify) {
|
|
|
453
453
|
});
|
|
454
454
|
fastify.addHook("onListen", async () => {
|
|
455
455
|
const clsQuery = [];
|
|
456
|
+
if (!client?.pk && client?.init) {
|
|
457
|
+
await client.init();
|
|
458
|
+
}
|
|
456
459
|
if (!client?.pk?.["admin.cls"])
|
|
457
460
|
return;
|
|
458
461
|
const selectList = getTemplatePath("select");
|
|
@@ -481,7 +484,7 @@ function plugin(fastify) {
|
|
|
481
484
|
el.hash = createHash("md5")
|
|
482
485
|
.update(type === "cls"
|
|
483
486
|
? JSON.stringify(loadTemplate)
|
|
484
|
-
: loadTemplate?.sql || loadTemplate)
|
|
487
|
+
: loadTemplate?.sql || loadTemplate || "")
|
|
485
488
|
.digest("hex");
|
|
486
489
|
el.dbhash = dbdata[name];
|
|
487
490
|
// check for changes by redis hash / dropped from db / changed at git project
|
|
@@ -20,7 +20,8 @@ export default async function authorizeUser(user, req, authType = "creds-user",
|
|
|
20
20
|
if (!user?.uid)
|
|
21
21
|
return "/logout";
|
|
22
22
|
const { pg = pgClients.client } = req;
|
|
23
|
-
|
|
23
|
+
const ip = getIp(req);
|
|
24
|
+
Object.assign(user, { auth_type: authType, ip });
|
|
24
25
|
// fastify/passport
|
|
25
26
|
await req.login(user);
|
|
26
27
|
const st = (req.body?.keep || req.query?.keep) === "on"
|
|
@@ -40,7 +41,6 @@ export default async function authorizeUser(user, req, authType = "creds-user",
|
|
|
40
41
|
.join(" "),
|
|
41
42
|
},
|
|
42
43
|
}, req);
|
|
43
|
-
const ip = getIp(req);
|
|
44
44
|
if (authType && authType.startsWith("creds")) {
|
|
45
45
|
await logAuth({
|
|
46
46
|
uid: user?.uid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadMultiPart.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/uploadMultiPart.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uploadMultiPart.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/uploadMultiPart.ts"],"names":[],"mappings":"AAqBA,UAAU,KAAK;IACb,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAyCD,wBAA8B,eAAe,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,gBAAwB,EAAE,GAAE,GAAQ,GAC9D,OAAO,CAAC,KAAK,CAAC,CAsFhB"}
|
|
@@ -9,6 +9,7 @@ import providers from "./providers/index.js";
|
|
|
9
9
|
import { all, images } from "./utils/allowedExtensions.js";
|
|
10
10
|
import grpc from "../grpc/grpc.js";
|
|
11
11
|
import getFileType from "./utils/getFileType.js";
|
|
12
|
+
import { BadRequestError } from "../../types/errors.js";
|
|
12
13
|
const { resizeImage } = grpc();
|
|
13
14
|
const { resizeImageMinSize = 5 } = config; // resize images >= 5 MB by default
|
|
14
15
|
async function writeFileToDisk(file, buffer) {
|
|
@@ -49,11 +50,11 @@ export default async function uploadMultiPart(req, { extensions, raw, subdir, or
|
|
|
49
50
|
}
|
|
50
51
|
const ext = path.extname(value.filename).toLowerCase();
|
|
51
52
|
if (Array.isArray(extensions) && !extensions.includes(ext)) {
|
|
52
|
-
throw new
|
|
53
|
+
throw new BadRequestError("file extension is not allowed");
|
|
53
54
|
}
|
|
54
55
|
// check extension
|
|
55
56
|
if (!allowedExtensions.includes(ext.substring(1))) {
|
|
56
|
-
throw new
|
|
57
|
+
throw new BadRequestError("file extension is not allowed");
|
|
57
58
|
}
|
|
58
59
|
const fileBuffer = await new Promise((res, rej) => {
|
|
59
60
|
const chunks = [];
|
|
@@ -62,7 +63,7 @@ export default async function uploadMultiPart(req, { extensions, raw, subdir, or
|
|
|
62
63
|
value.file.on("error", rej);
|
|
63
64
|
});
|
|
64
65
|
if (!fileBuffer?.length) {
|
|
65
|
-
throw new
|
|
66
|
+
throw new BadRequestError("file buffer is empty");
|
|
66
67
|
}
|
|
67
68
|
if (raw)
|
|
68
69
|
return { buffer: fileBuffer, filename: value.filename, ext }; // return buffer for custom upload
|
|
@@ -76,7 +77,7 @@ export default async function uploadMultiPart(req, { extensions, raw, subdir, or
|
|
|
76
77
|
? value.filename
|
|
77
78
|
: `${randomUUID()}${ext}`;
|
|
78
79
|
if (existsSync(path.join(folder, newFilename).replace(/\\/g, "/"))) {
|
|
79
|
-
throw new
|
|
80
|
+
throw new BadRequestError("file with specified name already exists in directory");
|
|
80
81
|
}
|
|
81
82
|
const file = {
|
|
82
83
|
originalFilename: value.filename,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMessage.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/errorMessage.ts"],"names":[],"mappings":"AAQA,iBAAS,YAAY,CAAC,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"errorMessage.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/errorMessage.ts"],"names":[],"mappings":"AAQA,iBAAS,YAAY,CAAC,KAAK,EAAE,GAAG,OAsB/B;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -17,6 +17,9 @@ function errorMessage(error) {
|
|
|
17
17
|
return config.errorMessage[status.toString()];
|
|
18
18
|
if (defaultMessage[status])
|
|
19
19
|
return defaultMessage[status];
|
|
20
|
+
if (error.statusCode && error.statusCode !== 500 && error.message) {
|
|
21
|
+
return config.errorMessage?.[error.statusCode] || error.message;
|
|
22
|
+
}
|
|
20
23
|
return config.local
|
|
21
24
|
? error.toString()
|
|
22
25
|
: config.errorMessage?.[500] || "ServerError";
|