@opengis/fastify-table 1.4.24 → 1.4.25

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.4.24",
3
+ "version": "1.4.25",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -8,7 +8,11 @@ export default async function getSettingsApp({
8
8
  }, reply) {
9
9
  const time = Date.now();
10
10
 
11
- if (!pg.pk?.[table]) {
11
+ if (!pg) {
12
+ return reply.status(500).send('empty pg');
13
+ }
14
+
15
+ if (!pg?.pk?.[table]) {
12
16
  return reply.status(404).send('table not found');
13
17
  }
14
18
 
@@ -26,6 +26,10 @@ export default async function postSettingsApp({
26
26
  return reply.status(400).send('not enough body params');
27
27
  }
28
28
 
29
+ if (!pg) {
30
+ return reply.status(500).send('empty pg');
31
+ }
32
+
29
33
  if (!pg?.pk?.[table]) {
30
34
  return reply.status(404).send('table not found');
31
35
  }
@@ -28,6 +28,10 @@ export default async function getSettingsTable({
28
28
  return reply.status(400).send('not enough params: table');
29
29
  }
30
30
 
31
+ if (!pg) {
32
+ return reply.status(500).send('empty pg');
33
+ }
34
+
31
35
  const loadTable = await getTemplate('table', table);
32
36
 
33
37
  const tableName = loadTable?.table || table;
@@ -28,6 +28,10 @@ export default async function postTablpostSettingsTableeProperties({
28
28
  return reply.status(400).send('not enough params: table');
29
29
  }
30
30
 
31
+ if (!pg) {
32
+ return reply.status(500).send('empty pg');
33
+ }
34
+
31
35
  const {
32
36
  deleted = [],
33
37
  columns = [],
@@ -20,16 +20,18 @@ const propertiesSchema = {
20
20
  },
21
21
  };
22
22
 
23
+ const policy = ['site']; // cms etc.
24
+
23
25
  async function plugin(app, config = {}) {
24
26
  const { prefix = '/api' } = config;
25
- app.get(`${prefix}/properties/:id`, { schema: propertiesSchema }, getExtraProperties);
26
- app.post(`${prefix}/properties/:id`, { schema: propertiesSchema }, addExtraProperties);
27
+ app.get(`${prefix}/properties/:id`, { config: { policy }, schema: propertiesSchema }, getExtraProperties);
28
+ app.post(`${prefix}/properties/:id`, { config: { policy }, schema: propertiesSchema }, addExtraProperties);
27
29
 
28
- app.get(`${prefix}/settings-app/:key?`, { scheme: propertiesSchema }, getSettingsApp);
30
+ app.get(`${prefix}/settings-app/:key?`, { config: { policy }, schema: propertiesSchema }, getSettingsApp);
29
31
  app.post(`${prefix}/settings-app`, { config: { policy: ['admin'] } }, postSettingsApp);
30
32
 
31
- app.get(`${prefix}/settings-table/:table/:entity?`, {}, getSettingsTable);
32
- app.post(`${prefix}/settings-table/:table`, {}, postSettingsTable);
33
+ app.get(`${prefix}/settings-table/:table/:entity?`, { config: { policy } }, getSettingsTable);
34
+ app.post(`${prefix}/settings-table/:table`, { config: { policy } }, postSettingsTable);
33
35
  }
34
36
 
35
37
  export default plugin;