@opengis/admin 0.1.67 → 0.1.68

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ const calendarDataSchema = {
2
+ params: {
3
+ name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
4
+ },
5
+ querystring: {
6
+ date: { type: 'string', pattern: '^([\\d\\s\\/,.:-]+)$' },
7
+ sql: { type: 'string', pattern: '^(\\d)$' },
8
+ },
9
+
10
+ // query: {
11
+ // type: 'object',
12
+ // properties: {
13
+ // date: {
14
+ // type: 'string',
15
+ // format: 'date',
16
+ // },
17
+ // },
18
+ // },
19
+ };
20
+
21
+ export { calendarDataSchema }
22
+ export default null;
@@ -5,11 +5,11 @@ import cardData from "./controllers/cardData.js";
5
5
  import cardTabData from './controllers/cardTabData.js';
6
6
  import tableFilter from "./controllers/tableFilter.js";
7
7
 
8
- import { tableDataSchema } from './schema.js';
8
+ import { tableDataSchema, tableDataIdSchema, tableFilterSchema, cardTabDataSchema } from './schema.js';
9
9
 
10
10
  export default async function route(fastify) {
11
11
  fastify.get(`/table-data/:table`, { schema: tableDataSchema }, tableData);
12
- fastify.get(`/card-data/:token`, cardTabData);
13
- fastify.get(`/table-data/:table/:id`, cardData);
14
- fastify.get(`/table-filter/:name`, tableFilter);
12
+ fastify.get(`/card-data/:token`, { scheme: cardTabDataSchema }, cardTabData);
13
+ fastify.get(`/table-data/:table/:id`, { schema: tableDataIdSchema }, cardData);
14
+ fastify.get(`/table-filter/:name`, { schema: tableFilterSchema }, tableFilter);
15
15
  }
@@ -1,7 +1,54 @@
1
1
  const tableDataSchema = {
2
2
  querystring: {
3
- limit: { type: 'integer' },
3
+ limit: { type: 'string', pattern: '^(\\d+)$' },
4
+ page: { type: 'string', pattern: '^(\\d+)$' },
5
+ filter: { type: 'string', pattern: '^([А-Яа-яҐґЄєІіЇї\\d\\w\\s(),.!?;:—_=-]+)$' },
6
+ search: { type: 'string', pattern: '^[А-Яа-яҐґЄєІіЇї\\d\\w\\s(),.!?;:—_=-]+$' },
7
+ order: { type: 'string', pattern: '^([\\d\\w_.-]+)$' },
8
+ desc: { type: 'string', pattern: '^(desc)|(asc)$' },
9
+ state: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
10
+ custom: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
11
+ bbox: { type: 'string', pattern: '^([\\d\\s,.-]+)$' },
12
+ polyline: { type: 'string', pattern: '^([\\d\\w|@{}~_`]+)$' },
13
+ // key: { type: 'string', pattern: '^([\\d\\w_]+)$' },
14
+ sql: { type: 'string', pattern: '^(\\d)$' },
15
+ },
16
+ params: {
17
+ id: { type: 'string', pattern: '^([\\d\\w]+)$' },
18
+ table: { type: 'string', pattern: '^([\\d\\w_.-]+)$' },
4
19
  }
5
20
  };
6
- export { tableDataSchema }
21
+
22
+ const tableDataIdSchema = {
23
+ params: {
24
+ id: { type: 'string', pattern: '^([\\d\\w]+)$' },
25
+ name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
26
+ }
27
+ };
28
+
29
+ const tableFilterSchema = {
30
+ params: {
31
+ name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
32
+ }
33
+ };
34
+
35
+ const cardDataSchema = {
36
+ params: {
37
+ id: { type: 'string', pattern: '^([\\d\\w]+)$' },
38
+ table: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
39
+ }
40
+ };
41
+
42
+ const cardTabDataSchema = {
43
+ querystring: {
44
+ sql: { type: 'string', pattern: '^(\\d)$' }
45
+ },
46
+ params: {
47
+ token: { type: 'string', pattern: '^([\\d\\w]+)$' },
48
+ }
49
+ };
50
+ export {
51
+ tableDataSchema, tableDataIdSchema, tableFilterSchema,
52
+ cardDataSchema, cardTabDataSchema
53
+ }
7
54
  export default null;
File without changes
@@ -6,35 +6,10 @@ import userNotifications from './controllers/userNotifications.js'; // check all
6
6
  // hook
7
7
  import onWidgetSet from './hook/onWidgetSet.js'; // send notification on comment
8
8
 
9
+ import { notificationSchema } from './schema.js';
9
10
 
10
- const tableSchema = {
11
- params: {
12
- id: { type: 'string' },
13
- },
14
- querystring: {
15
- nocache: { type: 'string', pattern: '^(\\d+)$' },
16
- },
17
- };
18
-
19
- export default async function plugin(fastify, config = {}) {
20
- const prefix = config.prefix || '/api';
21
- fastify.route({
22
- method: 'GET',
23
- url: '/notification',
24
- config: {
25
- policy: ['user'],
26
- },
27
- schema: tableSchema,
28
- handler: userNotifications,
29
- });
30
- fastify.route({
31
- method: 'GET',
32
- url: '/notification-read/:id?',
33
- config: {
34
- policy: ['user'],
35
- },
36
- schema: tableSchema,
37
- handler: readNotifications,
38
- });
39
- addHook('onWidgetSet', onWidgetSet);
11
+ export default async function route(fastify) {
12
+ fastify.get(`/notification`, { config: { policy: ['user'] }, schema: notificationSchema }, userNotifications);
13
+ fastify.get(`/notification-read/:id?`, { config: { policy: ['user'] }, schema: notificationSchema }, readNotifications);
14
+ addHook('onWidgetSet', onWidgetSet);
40
15
  }
@@ -0,0 +1,11 @@
1
+ const notificationSchema = {
2
+ params: {
3
+ id: { type: 'string', pattern: '^([\\d\\w]+)$' },
4
+ },
5
+ querystring: {
6
+ nocache: { type: 'string', pattern: '^(\\d+)$' },
7
+ },
8
+ };
9
+
10
+ export default null;
11
+ export { notificationSchema }
@@ -4,23 +4,11 @@ import postAdminProperties from './controllers/admin.properties.post.js';
4
4
  import getUserProperties from './controllers/user.properties.get.js';
5
5
  import postUserProperties from './controllers/user.properties.post.js';
6
6
 
7
- export default async function route(fastify) {
8
- fastify.get('/admin-properties/:key?', {}, getAdminProperties);
9
-
10
- fastify.route({
11
- method: 'POST',
12
- path: '/admin-properties',
13
- config: {
14
- policy: ['superadmin'],
15
- },
16
- handler: postAdminProperties,
17
- });
7
+ import { propertiesSchema } from './schema.js';
18
8
 
19
- fastify.get('/user-properties/:key?', {}, getUserProperties);
20
-
21
- fastify.route({
22
- method: 'POST',
23
- path: '/user-properties',
24
- handler: postUserProperties,
25
- });
9
+ export default async function route(fastify) {
10
+ fastify.get('/admin-properties/:key?', { scheme: propertiesSchema }, getAdminProperties);
11
+ fastify.get('/user-properties/:key?', { scheme: propertiesSchema }, getUserProperties);
12
+ fastify.post('/admin-properties', { config: { policy: ['superadmin'] } }, postAdminProperties);
13
+ fastify.post('/user-properties', postUserProperties);
26
14
  }
@@ -0,0 +1,11 @@
1
+ const propertiesSchema = {
2
+ params: {
3
+ key: { type: 'string', pattern: '^([\\d\\w._]+)$' },
4
+ },
5
+ querystring: {
6
+ json: { type: 'string', pattern: '^([\\d\\w]+)$' },
7
+ },
8
+ };
9
+
10
+ export default null;
11
+ export { propertiesSchema }
@@ -0,0 +1,9 @@
1
+ const getTemplateSchema = {
2
+ params: {
3
+ name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
4
+ // type: { type: 'string' },
5
+ }
6
+ };
7
+
8
+ export default null;
9
+ export { getTemplateSchema }