@opengis/fastify-table 2.0.60 → 2.0.61

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA6aA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QA0a3B;;AACD,wBAA0B"}
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
@@ -1 +1 @@
1
- {"version":3,"file":"uploadMultiPart.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/uploadMultiPart.ts"],"names":[],"mappings":"AAoBA,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,CAoFhB"}
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 Error("file extension is not allowed");
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 Error("file extension is not allowed");
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 Error("file buffer is empty");
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 Error("file with specified name already exists in directory");
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,OAkB/B;AAED,eAAe,YAAY,CAAC"}
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.60",
3
+ "version": "2.0.61",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [