-
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathpattern.js
More file actions
executable file
·34 lines (25 loc) · 883 Bytes
/
pattern.js
File metadata and controls
executable file
·34 lines (25 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const { getService } = require('../utils');
/**
* Sitemap.js controller
*
* @description: A set of functions called "actions" of the `sitemap` plugin.
*/
module.exports = {
allowedFields: async (ctx) => {
const formattedFields = {};
Object.values(strapi.contentTypes).map(async (contentType) => {
const fields = await getService('pattern').getAllowedFields(contentType);
formattedFields[contentType.uid] = fields;
});
ctx.send(formattedFields);
},
validatePattern: async (ctx) => {
const patternService = getService('pattern');
const { pattern, modelName } = ctx.request.body;
const contentType = strapi.contentTypes[modelName];
const fields = await patternService.getAllowedFields(contentType);
const validated = await patternService.validatePattern(pattern, fields);
ctx.send(validated);
},
};