@opengis/fastify-table 2.0.14 → 2.0.15

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.js CHANGED
@@ -311,6 +311,12 @@ function plugin(fastify) {
311
311
  keyGenerator: (req) => `${req.ip}-${req.raw.url.split("?")[0]}`,
312
312
  });
313
313
  }
314
+ // add multipart parser before any route registration
315
+ fastify.register(import("@fastify/multipart"), {
316
+ limits: {
317
+ fileSize: maxFileSize * 1024 * 1024,
318
+ },
319
+ });
314
320
  if (config.dblist) {
315
321
  fastify.register(dblistRoutes, opt);
316
322
  }
@@ -327,11 +333,6 @@ function plugin(fastify) {
327
333
  fastify.register(templatesRoutes, opt);
328
334
  fastify.register(authRoutes); // from fastify-auth
329
335
  // from fastify-file
330
- fastify.register(import("@fastify/multipart"), {
331
- limits: {
332
- fileSize: maxFileSize * 1024 * 1024,
333
- },
334
- }); // content parser, await before adding upload routes
335
336
  fastify.register(fileRoutes);
336
337
  fastify.register(grpcRoutes, opt);
337
338
  config.proxy?.forEach?.((el) => {
@@ -28,10 +28,10 @@ export default async function getForm({ pg = pgClients.client, params, user = {}
28
28
  (await getTemplate("table", table).then((el) => el?.form)) ||
29
29
  {};
30
30
  if (!form) {
31
- return reply.status(404).send("form not found");
31
+ // return reply.status(404).send("form not found");
32
32
  }
33
33
  const { actions = [] } = (await getAccess({ table, form, user }, pg)) || {};
34
- const loadTemplate = form ? await getTemplate("form", form) : null;
34
+ const loadTemplate = await getTemplate("form", form || params.name);
35
35
  if (!loadTemplate) {
36
36
  return reply.status(404).send("form template not found");
37
37
  }
@@ -56,7 +56,8 @@ export default async function getForm({ pg = pgClients.client, params, user = {}
56
56
  if (!isAllowedByTemplate &&
57
57
  !config.local &&
58
58
  process.env.NODE_ENV !== "test" &&
59
- !(tokenData?.form || hookData?.form)) {
59
+ !(tokenData?.form || hookData?.form) &&
60
+ form) {
60
61
  return reply.status(403).send("access restricted: actions");
61
62
  }
62
63
  const token = setToken({
@@ -61,5 +61,8 @@ export default async function getTemplateApi(req) {
61
61
  data,
62
62
  user,
63
63
  });
64
+ if (type === "form" && data && !data?.schema) {
65
+ return { schema: data };
66
+ }
64
67
  return data?.html || data || `template not found "${tokenData.form || name}"`;
65
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.14",
3
+ "version": "2.0.15",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [