mirror of
https://github.com/strapi/strapi.git
synced 2025-10-08 23:04:02 +00:00
commit
59b83c5953
@ -26,14 +26,16 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
'prefer-destructuring': ['error', { AssignmentExpression: { array: false } }],
|
'prefer-destructuring': ['error', { AssignmentExpression: { array: false } }],
|
||||||
eqeqeq: 'warn',
|
'no-underscore-dangle': 'off',
|
||||||
'no-underscore-dangle': 'warn',
|
'no-use-before-define': 'off',
|
||||||
'no-use-before-define': 'warn',
|
|
||||||
'no-param-reassign': 'warn',
|
|
||||||
'no-continue': 'warn',
|
'no-continue': 'warn',
|
||||||
'no-process-exit': 'off',
|
'no-process-exit': 'off',
|
||||||
'no-plusplus': 'warn',
|
'no-loop-func': 'off',
|
||||||
'no-loop-func': 'warn',
|
'no-param-reassign': [
|
||||||
'guard-for-in': 'warn',
|
'error',
|
||||||
|
{
|
||||||
|
props: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -80,12 +80,10 @@ const buildAdmin = async () => {
|
|||||||
new Error(
|
new Error(
|
||||||
messages.errors.reduce((acc, error) => {
|
messages.errors.reduce((acc, error) => {
|
||||||
if (isObject(error)) {
|
if (isObject(error)) {
|
||||||
acc += error.message;
|
return acc + error.message;
|
||||||
} else {
|
|
||||||
acc += error.join('\n\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc + error.join('\n\n');
|
||||||
}, '')
|
}, '')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -426,7 +426,11 @@ describe('Role', () => {
|
|||||||
|
|
||||||
const count = jest.fn(() => Promise.resolve(0));
|
const count = jest.fn(() => Promise.resolve(0));
|
||||||
let id = 1;
|
let id = 1;
|
||||||
const create = jest.fn(({ data }) => ({ ...data, id: id++ }));
|
const create = jest.fn(({ data }) => {
|
||||||
|
const res = { ...data, id };
|
||||||
|
id += 1;
|
||||||
|
return res;
|
||||||
|
});
|
||||||
const values = jest.fn(() => actions);
|
const values = jest.fn(() => actions);
|
||||||
const createMany = jest.fn();
|
const createMany = jest.fn();
|
||||||
const assignARoleToAll = jest.fn();
|
const assignARoleToAll = jest.fn();
|
||||||
|
@ -49,9 +49,10 @@ const unwrapDeep = (obj) => {
|
|||||||
|
|
||||||
if (_.isPlainObject(v)) {
|
if (_.isPlainObject(v)) {
|
||||||
if ('$elemMatch' in v) {
|
if ('$elemMatch' in v) {
|
||||||
v = v.$elemMatch; // removing this key
|
_.setWith(acc, key, unwrapDeep(v.$elemMatch));
|
||||||
|
} else {
|
||||||
|
_.setWith(acc, key, unwrapDeep(v));
|
||||||
}
|
}
|
||||||
_.setWith(acc, key, unwrapDeep(v));
|
|
||||||
} else if (_.isArray(v)) {
|
} else if (_.isArray(v)) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
_.setWith(acc, key, v.map(v => unwrapDeep(v)));
|
_.setWith(acc, key, v.map(v => unwrapDeep(v)));
|
||||||
|
@ -144,7 +144,7 @@ const cleanPermissionsInDatabase = async () => {
|
|||||||
const total = await strapi.query('admin::permission').count();
|
const total = await strapi.query('admin::permission').count();
|
||||||
const pageCount = Math.ceil(total / pageSize);
|
const pageCount = Math.ceil(total / pageSize);
|
||||||
|
|
||||||
for (let page = 0; page < pageCount; page++) {
|
for (let page = 0; page < pageCount; page += 1) {
|
||||||
// 1. Find invalid permissions and collect their ID to delete them later
|
// 1. Find invalid permissions and collect their ID to delete them later
|
||||||
const results = await strapi
|
const results = await strapi
|
||||||
.query('admin::permission')
|
.query('admin::permission')
|
||||||
|
@ -84,7 +84,7 @@ if (edition === 'EE') {
|
|||||||
// Create users with the new role & create associated auth requests
|
// Create users with the new role & create associated auth requests
|
||||||
const users = [];
|
const users = [];
|
||||||
|
|
||||||
for (let i = 0; i < localTestData.users.length; ++i) {
|
for (let i = 0; i < localTestData.users.length; i += 1) {
|
||||||
const userFixture = localTestData.users[i];
|
const userFixture = localTestData.users[i];
|
||||||
const userAttributes = {
|
const userAttributes = {
|
||||||
...userFixture,
|
...userFixture,
|
||||||
|
@ -145,7 +145,7 @@ describe('Admin User CRUD (e2e)', () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i += 1) {
|
||||||
const res = await rq({
|
const res = await rq({
|
||||||
url: '/admin/users',
|
url: '/admin/users',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -12,7 +12,7 @@ const checkFieldsAreCorrectlyNested = (fields) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let failed = false;
|
let failed = false;
|
||||||
for (let indexA = 0; indexA < fields.length; indexA++) {
|
for (let indexA = 0; indexA < fields.length; indexA += 1) {
|
||||||
failed = fields
|
failed = fields
|
||||||
.slice(indexA + 1)
|
.slice(indexA + 1)
|
||||||
.some(
|
.some(
|
||||||
|
@ -69,7 +69,7 @@ module.exports = ({ strapi }) => ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in model.attributes) {
|
for (const key of Object.keys(model.attributes)) {
|
||||||
const attribute = model.attributes[key];
|
const attribute = model.attributes[key];
|
||||||
|
|
||||||
if (attribute.type === 'component') {
|
if (attribute.type === 'component') {
|
||||||
|
@ -130,7 +130,7 @@ module.exports = function createSchemaHandler(infos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set new Attributes
|
// set new Attributes
|
||||||
for (const key in newAttributes) {
|
for (const key of Object.keys(newAttributes)) {
|
||||||
this.setAttribute(key, newAttributes[key]);
|
this.setAttribute(key, newAttributes[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ describe('Content Type Builder - Content types', () => {
|
|||||||
const { uid } = createRes.body.data;
|
const { uid } = createRes.body.data;
|
||||||
|
|
||||||
// create data
|
// create data
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i += 1) {
|
||||||
await strapi.query(uid).create({ data: { title: 'Test' } });
|
await strapi.query(uid).create({ data: { title: 'Test' } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ const processData = (metadata, data = {}, { withDefaults = false } = {}) => {
|
|||||||
|
|
||||||
const obj = {};
|
const obj = {};
|
||||||
|
|
||||||
for (const attributeName in attributes) {
|
for (const attributeName of Object.keys(attributes)) {
|
||||||
const attribute = attributes[attributeName];
|
const attribute = attributes[attributeName];
|
||||||
|
|
||||||
if (types.isScalar(attribute.type)) {
|
if (types.isScalar(attribute.type)) {
|
||||||
@ -333,7 +333,7 @@ const createEntityManager = (db) => {
|
|||||||
async attachRelations(uid, id, data) {
|
async attachRelations(uid, id, data) {
|
||||||
const { attributes } = db.metadata.get(uid);
|
const { attributes } = db.metadata.get(uid);
|
||||||
|
|
||||||
for (const attributeName in attributes) {
|
for (const attributeName of Object.keys(attributes)) {
|
||||||
const attribute = attributes[attributeName];
|
const attribute = attributes[attributeName];
|
||||||
|
|
||||||
const isValidLink = _.has(attributeName, data) && !_.isNil(data[attributeName]);
|
const isValidLink = _.has(attributeName, data) && !_.isNil(data[attributeName]);
|
||||||
@ -487,7 +487,7 @@ const createEntityManager = (db) => {
|
|||||||
async updateRelations(uid, id, data) {
|
async updateRelations(uid, id, data) {
|
||||||
const { attributes } = db.metadata.get(uid);
|
const { attributes } = db.metadata.get(uid);
|
||||||
|
|
||||||
for (const attributeName in attributes) {
|
for (const attributeName of Object.keys(attributes)) {
|
||||||
const attribute = attributes[attributeName];
|
const attribute = attributes[attributeName];
|
||||||
|
|
||||||
if (attribute.type !== 'relation' || !_.has(attributeName, data)) {
|
if (attribute.type !== 'relation' || !_.has(attributeName, data)) {
|
||||||
@ -667,7 +667,7 @@ const createEntityManager = (db) => {
|
|||||||
async deleteRelations(uid, id) {
|
async deleteRelations(uid, id) {
|
||||||
const { attributes } = db.metadata.get(uid);
|
const { attributes } = db.metadata.get(uid);
|
||||||
|
|
||||||
for (const attributeName in attributes) {
|
for (const attributeName of Object.keys(attributes)) {
|
||||||
const attribute = attributes[attributeName];
|
const attribute = attributes[attributeName];
|
||||||
|
|
||||||
if (attribute.type !== 'relation') {
|
if (attribute.type !== 'relation') {
|
||||||
|
@ -54,7 +54,7 @@ const createLifecyclesProvider = (db) => {
|
|||||||
* @param {Map<any, any>} states
|
* @param {Map<any, any>} states
|
||||||
*/
|
*/
|
||||||
async run(action, uid, properties, states = new Map()) {
|
async run(action, uid, properties, states = new Map()) {
|
||||||
for (let i = 0; i < subscribers.length; i++) {
|
for (let i = 0; i < subscribers.length; i += 1) {
|
||||||
const subscriber = subscribers[i];
|
const subscriber = subscribers[i];
|
||||||
if (typeof subscriber === 'function') {
|
if (typeof subscriber === 'function') {
|
||||||
const state = states.get(subscriber) || {};
|
const state = states.get(subscriber) || {};
|
||||||
|
@ -71,7 +71,7 @@ const applyJoin = (qb, join) => {
|
|||||||
inner.on(`${rootTable}.${rootColumn}`, `${alias}.${referencedColumn}`);
|
inner.on(`${rootTable}.${rootColumn}`, `${alias}.${referencedColumn}`);
|
||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
for (const key in on) {
|
for (const key of Object.keys(on)) {
|
||||||
inner.onVal(`${alias}.${key}`, on[key]);
|
inner.onVal(`${alias}.${key}`, on[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ const { fromRow } = require('./transform');
|
|||||||
const getRootLevelPopulate = (meta) => {
|
const getRootLevelPopulate = (meta) => {
|
||||||
const populate = {};
|
const populate = {};
|
||||||
|
|
||||||
for (const attributeName in meta.attributes) {
|
for (const attributeName of Object.keys(meta.attributes)) {
|
||||||
const attribute = meta.attributes[attributeName];
|
const attribute = meta.attributes[attributeName];
|
||||||
if (attribute.type === 'relation') {
|
if (attribute.type === 'relation') {
|
||||||
populate[attributeName] = true;
|
populate[attributeName] = true;
|
||||||
@ -72,7 +72,7 @@ const processPopulate = (populate, ctx) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const finalPopulate = {};
|
const finalPopulate = {};
|
||||||
for (const key in populateMap) {
|
for (const key of Object.keys(populateMap)) {
|
||||||
const attribute = meta.attributes[key];
|
const attribute = meta.attributes[key];
|
||||||
|
|
||||||
if (!attribute) {
|
if (!attribute) {
|
||||||
@ -119,7 +119,7 @@ const applyPopulate = async (results, populate, ctx) => {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in populate) {
|
for (const key of Object.keys(populate)) {
|
||||||
const attribute = meta.attributes[key];
|
const attribute = meta.attributes[key];
|
||||||
const targetMeta = db.metadata.get(attribute.target);
|
const targetMeta = db.metadata.get(attribute.target);
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ const applyPopulate = async (results, populate, ctx) => {
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const map = {};
|
const map = {};
|
||||||
for (const type in idsByType) {
|
for (const type of Object.keys(idsByType)) {
|
||||||
const ids = idsByType[type];
|
const ids = idsByType[type];
|
||||||
|
|
||||||
// type was removed but still in morph relation
|
// type was removed but still in morph relation
|
||||||
@ -604,7 +604,7 @@ const applyPopulate = async (results, populate, ctx) => {
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const map = {};
|
const map = {};
|
||||||
for (const type in idsByType) {
|
for (const type of Object.keys(idsByType)) {
|
||||||
const ids = idsByType[type];
|
const ids = idsByType[type];
|
||||||
|
|
||||||
// type was removed but still in morph relation
|
// type was removed but still in morph relation
|
||||||
|
@ -53,7 +53,7 @@ const toRow = (meta, data = {}) => {
|
|||||||
|
|
||||||
const { attributes } = meta;
|
const { attributes } = meta;
|
||||||
|
|
||||||
for (const key in data) {
|
for (const key of Object.keys(data)) {
|
||||||
const attribute = attributes[key];
|
const attribute = attributes[key];
|
||||||
|
|
||||||
if (!attribute || attribute.columnName === key) {
|
if (!attribute || attribute.columnName === key) {
|
||||||
|
@ -76,7 +76,7 @@ const processAttributeWhere = (attribute, where, operator = '$eq') => {
|
|||||||
|
|
||||||
const filters = {};
|
const filters = {};
|
||||||
|
|
||||||
for (const key in where) {
|
for (const key of Object.keys(where)) {
|
||||||
const value = where[key];
|
const value = where[key];
|
||||||
|
|
||||||
if (!isOperator(key)) {
|
if (!isOperator(key)) {
|
||||||
@ -119,7 +119,7 @@ const processWhere = (where, ctx) => {
|
|||||||
const filters = {};
|
const filters = {};
|
||||||
|
|
||||||
// for each key in where
|
// for each key in where
|
||||||
for (const key in where) {
|
for (const key of Object.keys(where)) {
|
||||||
const value = where[key];
|
const value = where[key];
|
||||||
|
|
||||||
// if operator $and $or then loop over them
|
// if operator $and $or then loop over them
|
||||||
|
@ -27,7 +27,13 @@ const createQueryBuilder = (uid, db) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
const getAlias = () => `t${counter++}`;
|
const getAlias = () => {
|
||||||
|
const alias = `t${counter}`;
|
||||||
|
|
||||||
|
counter += 1;
|
||||||
|
|
||||||
|
return alias;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
alias: getAlias(),
|
alias: getAlias(),
|
||||||
|
@ -25,7 +25,7 @@ const createTable = (meta) => {
|
|||||||
columns: [],
|
columns: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in meta.attributes) {
|
for (const key of Object.keys(meta.attributes)) {
|
||||||
const attribute = meta.attributes[key];
|
const attribute = meta.attributes[key];
|
||||||
|
|
||||||
if (types.isRelation(attribute.type)) {
|
if (types.isRelation(attribute.type)) {
|
||||||
|
@ -9,7 +9,7 @@ const CHUNK_SIZE = 100;
|
|||||||
* Will dump configurations to a file or stdout
|
* Will dump configurations to a file or stdout
|
||||||
* @param {string} file filepath to use as output
|
* @param {string} file filepath to use as output
|
||||||
*/
|
*/
|
||||||
module.exports = async function ({ file: filePath, pretty }) {
|
module.exports = async ({ file: filePath, pretty }) => {
|
||||||
const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
|
const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
|
||||||
|
|
||||||
const appContext = await strapi.compile();
|
const appContext = await strapi.compile();
|
||||||
@ -21,7 +21,7 @@ module.exports = async function ({ file: filePath, pretty }) {
|
|||||||
|
|
||||||
const pageCount = Math.ceil(count / CHUNK_SIZE);
|
const pageCount = Math.ceil(count / CHUNK_SIZE);
|
||||||
|
|
||||||
for (let page = 0; page < pageCount; page++) {
|
for (let page = 0; page < pageCount; page += 1) {
|
||||||
const results = await app
|
const results = await app
|
||||||
.query('strapi::core-store')
|
.query('strapi::core-store')
|
||||||
.findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: 'key' });
|
.findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: 'key' });
|
||||||
|
@ -56,7 +56,7 @@ const transformEntry = (entry, type) => {
|
|||||||
|
|
||||||
const attributeValues = {};
|
const attributeValues = {};
|
||||||
|
|
||||||
for (const key in properties) {
|
for (const key of Object.keys(properties)) {
|
||||||
const property = properties[key];
|
const property = properties[key];
|
||||||
const attribute = type && type.attributes[key];
|
const attribute = type && type.attributes[key];
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ module.exports = async (strapi) => {
|
|||||||
|
|
||||||
validateContentTypesUnicity(apis);
|
validateContentTypesUnicity(apis);
|
||||||
|
|
||||||
for (const apiName in apis) {
|
for (const apiName of Object.keys(apis)) {
|
||||||
strapi.container.get('apis').add(apiName, apis[apiName]);
|
strapi.container.get('apis').add(apiName, apis[apiName]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,9 @@ const getEnabledPlugins = async (strapi) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const installedPlugins = {};
|
const installedPlugins = {};
|
||||||
for (const dep in strapi.config.get('info.dependencies', {})) {
|
const dependencies = strapi.config.get('info.dependencies', {});
|
||||||
|
|
||||||
|
for (const dep of Object.keys(dependencies)) {
|
||||||
const packagePath = join(dep, 'package.json');
|
const packagePath = join(dep, 'package.json');
|
||||||
let packageInfo;
|
let packageInfo;
|
||||||
try {
|
try {
|
||||||
|
@ -34,10 +34,10 @@ const applyUserExtension = async (plugins) => {
|
|||||||
const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');
|
const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');
|
||||||
const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');
|
const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');
|
||||||
|
|
||||||
for (const pluginName in plugins) {
|
for (const pluginName of Object.keys(plugins)) {
|
||||||
const plugin = plugins[pluginName];
|
const plugin = plugins[pluginName];
|
||||||
// first: load json schema
|
// first: load json schema
|
||||||
for (const ctName in plugin.contentTypes) {
|
for (const ctName of Object.keys(plugin.contentTypes)) {
|
||||||
const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);
|
const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);
|
||||||
if (extendedSchema) {
|
if (extendedSchema) {
|
||||||
plugin.contentTypes[ctName].schema = {
|
plugin.contentTypes[ctName].schema = {
|
||||||
@ -57,7 +57,7 @@ const applyUserExtension = async (plugins) => {
|
|||||||
const applyUserConfig = async (plugins) => {
|
const applyUserConfig = async (plugins) => {
|
||||||
const userPluginsConfig = await getUserPluginsConfig();
|
const userPluginsConfig = await getUserPluginsConfig();
|
||||||
|
|
||||||
for (const pluginName in plugins) {
|
for (const pluginName of Object.keys(plugins)) {
|
||||||
const plugin = plugins[pluginName];
|
const plugin = plugins[pluginName];
|
||||||
const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);
|
const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);
|
||||||
const defaultConfig =
|
const defaultConfig =
|
||||||
@ -82,7 +82,7 @@ const loadPlugins = async (strapi) => {
|
|||||||
|
|
||||||
strapi.config.set('enabledPlugins', enabledPlugins);
|
strapi.config.set('enabledPlugins', enabledPlugins);
|
||||||
|
|
||||||
for (const pluginName in enabledPlugins) {
|
for (const pluginName of Object.keys(enabledPlugins)) {
|
||||||
const enabledPlugin = enabledPlugins[pluginName];
|
const enabledPlugin = enabledPlugins[pluginName];
|
||||||
|
|
||||||
const serverEntrypointPath = join(enabledPlugin.pathToPlugin, 'strapi-server.js');
|
const serverEntrypointPath = join(enabledPlugin.pathToPlugin, 'strapi-server.js');
|
||||||
@ -100,7 +100,7 @@ const loadPlugins = async (strapi) => {
|
|||||||
await applyUserConfig(plugins);
|
await applyUserConfig(plugins);
|
||||||
await applyUserExtension(plugins);
|
await applyUserExtension(plugins);
|
||||||
|
|
||||||
for (const pluginName in plugins) {
|
for (const pluginName of Object.keys(plugins)) {
|
||||||
strapi.container.get('plugins').add(pluginName, plugins[pluginName]);
|
strapi.container.get('plugins').add(pluginName, plugins[pluginName]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ const { createContentType } = require('../domain/content-type');
|
|||||||
const { addNamespace, hasNamespace } = require('../utils');
|
const { addNamespace, hasNamespace } = require('../utils');
|
||||||
|
|
||||||
const validateKeySameToSingularName = (contentTypes) => {
|
const validateKeySameToSingularName = (contentTypes) => {
|
||||||
for (const ctName in contentTypes) {
|
for (const ctName of Object.keys(contentTypes)) {
|
||||||
const contentType = contentTypes[ctName];
|
const contentType = contentTypes[ctName];
|
||||||
|
|
||||||
if (ctName !== contentType.schema.info.singularName) {
|
if (ctName !== contentType.schema.info.singularName) {
|
||||||
@ -63,7 +63,7 @@ const contentTypesRegistry = () => {
|
|||||||
add(namespace, newContentTypes) {
|
add(namespace, newContentTypes) {
|
||||||
validateKeySameToSingularName(newContentTypes);
|
validateKeySameToSingularName(newContentTypes);
|
||||||
|
|
||||||
for (const rawCtName in newContentTypes) {
|
for (const rawCtName of Object.keys(newContentTypes)) {
|
||||||
const uid = addNamespace(rawCtName, namespace);
|
const uid = addNamespace(rawCtName, namespace);
|
||||||
|
|
||||||
if (has(uid, contentTypes)) {
|
if (has(uid, contentTypes)) {
|
||||||
|
@ -48,7 +48,7 @@ const controllersRegistry = () => {
|
|||||||
const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);
|
const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);
|
||||||
|
|
||||||
const map = {};
|
const map = {};
|
||||||
for (const uid in filteredControllers) {
|
for (const uid of Object.keys(filteredControllers)) {
|
||||||
Object.defineProperty(map, uid, {
|
Object.defineProperty(map, uid, {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: () => {
|
get: () => {
|
||||||
@ -78,7 +78,7 @@ const controllersRegistry = () => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(namespace, newControllers) {
|
add(namespace, newControllers) {
|
||||||
for (const controllerName in newControllers) {
|
for (const controllerName of Object.keys(newControllers)) {
|
||||||
const controller = newControllers[controllerName];
|
const controller = newControllers[controllerName];
|
||||||
const uid = addNamespace(controllerName, namespace);
|
const uid = addNamespace(controllerName, namespace);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ const hooksRegistry = () => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(namespace, hooks) {
|
add(namespace, hooks) {
|
||||||
for (const hookName in hooks) {
|
for (const hookName of Object.keys(hooks)) {
|
||||||
const hook = hooks[hookName];
|
const hook = hooks[hookName];
|
||||||
const uid = addNamespace(hookName, namespace);
|
const uid = addNamespace(hookName, namespace);
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ const middlewaresRegistry = () => {
|
|||||||
* @param {{ [key: string]: Middleware }} newMiddlewares
|
* @param {{ [key: string]: Middleware }} newMiddlewares
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(namespace, rawMiddlewares) {
|
add(namespace, rawMiddlewares = {}) {
|
||||||
for (const middlewareName in rawMiddlewares) {
|
for (const middlewareName of Object.keys(rawMiddlewares)) {
|
||||||
const middleware = rawMiddlewares[middlewareName];
|
const middleware = rawMiddlewares[middlewareName];
|
||||||
const uid = addNamespace(middlewareName, namespace);
|
const uid = addNamespace(middlewareName, namespace);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ const policiesRegistry = () => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(namespace, newPolicies) {
|
add(namespace, newPolicies) {
|
||||||
for (const policyName in newPolicies) {
|
for (const policyName of Object.keys(newPolicies)) {
|
||||||
const policy = newPolicies[policyName];
|
const policy = newPolicies[policyName];
|
||||||
const uid = addNamespace(policyName, namespace);
|
const uid = addNamespace(policyName, namespace);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ const servicesRegistry = (strapi) => {
|
|||||||
|
|
||||||
// create lazy accessor to avoid instantiating the services;
|
// create lazy accessor to avoid instantiating the services;
|
||||||
const map = {};
|
const map = {};
|
||||||
for (const uid in filteredServices) {
|
for (const uid of Object.keys(filteredServices)) {
|
||||||
Object.defineProperty(map, uid, {
|
Object.defineProperty(map, uid, {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: () => {
|
get: () => {
|
||||||
@ -78,7 +78,7 @@ const servicesRegistry = (strapi) => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
add(namespace, newServices) {
|
add(namespace, newServices) {
|
||||||
for (const serviceName in newServices) {
|
for (const serviceName of Object.keys(newServices)) {
|
||||||
const service = newServices[serviceName];
|
const service = newServices[serviceName];
|
||||||
const uid = addNamespace(serviceName, namespace);
|
const uid = addNamespace(serviceName, namespace);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ const createCronService = () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
add(tasks = {}) {
|
add(tasks = {}) {
|
||||||
for (const taskExpression in tasks) {
|
for (const taskExpression of Object.keys(tasks)) {
|
||||||
const taskValue = tasks[taskExpression];
|
const taskValue = tasks[taskExpression];
|
||||||
|
|
||||||
let fn;
|
let fn;
|
||||||
|
@ -18,11 +18,11 @@ const omitComponentData = (contentType, data) => {
|
|||||||
|
|
||||||
// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
|
// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
|
||||||
const createComponents = async (uid, data) => {
|
const createComponents = async (uid, data) => {
|
||||||
const { attributes } = strapi.getModel(uid);
|
const { attributes = {} } = strapi.getModel(uid);
|
||||||
|
|
||||||
const componentBody = {};
|
const componentBody = {};
|
||||||
|
|
||||||
for (const attributeName in attributes) {
|
for (const attributeName of Object.keys(attributes)) {
|
||||||
const attribute = attributes[attributeName];
|
const attribute = attributes[attributeName];
|
||||||
|
|
||||||
if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {
|
if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {
|
||||||
@ -118,11 +118,11 @@ const getComponents = async (uid, entity) => {
|
|||||||
create or update
|
create or update
|
||||||
*/
|
*/
|
||||||
const updateComponents = async (uid, entityToUpdate, data) => {
|
const updateComponents = async (uid, entityToUpdate, data) => {
|
||||||
const { attributes } = strapi.getModel(uid);
|
const { attributes = {} } = strapi.getModel(uid);
|
||||||
|
|
||||||
const componentBody = {};
|
const componentBody = {};
|
||||||
|
|
||||||
for (const attributeName in attributes) {
|
for (const attributeName of Object.keys(attributes)) {
|
||||||
const attribute = attributes[attributeName];
|
const attribute = attributes[attributeName];
|
||||||
|
|
||||||
if (!has(attributeName, data)) {
|
if (!has(attributeName, data)) {
|
||||||
@ -275,9 +275,9 @@ const deleteOldDZComponents = async (uid, entityToUpdate, attributeName, dynamic
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteComponents = async (uid, entityToDelete) => {
|
const deleteComponents = async (uid, entityToDelete) => {
|
||||||
const { attributes } = strapi.getModel(uid);
|
const { attributes = {} } = strapi.getModel(uid);
|
||||||
|
|
||||||
for (const attributeName in attributes) {
|
for (const attributeName of Object.keys(attributes)) {
|
||||||
const attribute = attributes[attributeName];
|
const attribute = attributes[attributeName];
|
||||||
|
|
||||||
if (attribute.type === 'component') {
|
if (attribute.type === 'component') {
|
||||||
|
@ -14,51 +14,56 @@ const { isMediaAttribute, isScalarAttribute, getWritableAttributes } = strapiUti
|
|||||||
const { ValidationError } = strapiUtils.errors;
|
const { ValidationError } = strapiUtils.errors;
|
||||||
|
|
||||||
const addMinMax = (validator, { attr, updatedAttribute }) => {
|
const addMinMax = (validator, { attr, updatedAttribute }) => {
|
||||||
|
let nextValidator = validator;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Number.isInteger(attr.min) &&
|
Number.isInteger(attr.min) &&
|
||||||
(attr.required || (Array.isArray(updatedAttribute.value) && updatedAttribute.value.length > 0))
|
(attr.required || (Array.isArray(updatedAttribute.value) && updatedAttribute.value.length > 0))
|
||||||
) {
|
) {
|
||||||
validator = validator.min(attr.min);
|
nextValidator = nextValidator.min(attr.min);
|
||||||
}
|
}
|
||||||
if (Number.isInteger(attr.max)) {
|
if (Number.isInteger(attr.max)) {
|
||||||
validator = validator.max(attr.max);
|
nextValidator = nextValidator.max(attr.max);
|
||||||
}
|
}
|
||||||
return validator;
|
return nextValidator;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addRequiredValidation =
|
const addRequiredValidation = (createOrUpdate) => {
|
||||||
(createOrUpdate) =>
|
return (validator, { attr: { required } }) => {
|
||||||
(validator, { attr: { required } }) => {
|
let nextValidator = validator;
|
||||||
if (required) {
|
if (required) {
|
||||||
if (createOrUpdate === 'creation') {
|
if (createOrUpdate === 'creation') {
|
||||||
validator = validator.notNil();
|
nextValidator = nextValidator.notNil();
|
||||||
} else if (createOrUpdate === 'update') {
|
} else if (createOrUpdate === 'update') {
|
||||||
validator = validator.notNull();
|
nextValidator = nextValidator.notNull();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
validator = validator.nullable();
|
nextValidator = nextValidator.nullable();
|
||||||
}
|
}
|
||||||
return validator;
|
return nextValidator;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const addDefault = (createOrUpdate) => {
|
||||||
|
return (validator, { attr }) => {
|
||||||
|
let nextValidator = validator;
|
||||||
|
|
||||||
const addDefault =
|
|
||||||
(createOrUpdate) =>
|
|
||||||
(validator, { attr }) => {
|
|
||||||
if (createOrUpdate === 'creation') {
|
if (createOrUpdate === 'creation') {
|
||||||
if (
|
if (
|
||||||
((attr.type === 'component' && attr.repeatable) || attr.type === 'dynamiczone') &&
|
((attr.type === 'component' && attr.repeatable) || attr.type === 'dynamiczone') &&
|
||||||
!attr.required
|
!attr.required
|
||||||
) {
|
) {
|
||||||
validator = validator.default([]);
|
nextValidator = nextValidator.default([]);
|
||||||
} else {
|
} else {
|
||||||
validator = validator.default(attr.default);
|
nextValidator = nextValidator.default(attr.default);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
validator = validator.default(undefined);
|
nextValidator = nextValidator.default(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
return validator;
|
return nextValidator;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const preventCast = (validator) => validator.transform((val, originalVal) => originalVal);
|
const preventCast = (validator) => validator.transform((val, originalVal) => originalVal);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ describe('Metrics middleware', () => {
|
|||||||
const sendEvent = jest.fn();
|
const sendEvent = jest.fn();
|
||||||
const middleware = createMiddleware({ sendEvent });
|
const middleware = createMiddleware({ sendEvent });
|
||||||
|
|
||||||
for (let i = 0; i < 2000; i++) {
|
for (let i = 0; i < 2000; i += 1) {
|
||||||
await middleware(
|
await middleware(
|
||||||
{
|
{
|
||||||
request: {
|
request: {
|
||||||
|
@ -22,7 +22,7 @@ const createMiddleware = ({ sendEvent }) => {
|
|||||||
sendEvent('didReceiveRequest', { url: ctx.request.url });
|
sendEvent('didReceiveRequest', { url: ctx.request.url });
|
||||||
|
|
||||||
// Increase counter.
|
// Increase counter.
|
||||||
_state.counter++;
|
_state.counter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ const registerAdminRoutes = (strapi) => {
|
|||||||
* @param {import('../../').Strapi} strapi
|
* @param {import('../../').Strapi} strapi
|
||||||
*/
|
*/
|
||||||
const registerPluginRoutes = (strapi) => {
|
const registerPluginRoutes = (strapi) => {
|
||||||
for (const pluginName in strapi.plugins) {
|
for (const pluginName of Object.keys(strapi.plugins)) {
|
||||||
const plugin = strapi.plugins[pluginName];
|
const plugin = strapi.plugins[pluginName];
|
||||||
|
|
||||||
const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);
|
const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);
|
||||||
@ -86,7 +86,7 @@ const registerPluginRoutes = (strapi) => {
|
|||||||
* @param {import('../../').Strapi} strapi
|
* @param {import('../../').Strapi} strapi
|
||||||
*/
|
*/
|
||||||
const registerAPIRoutes = (strapi) => {
|
const registerAPIRoutes = (strapi) => {
|
||||||
for (const apiName in strapi.api) {
|
for (const apiName of Object.keys(strapi.api)) {
|
||||||
const api = strapi.api[apiName];
|
const api = strapi.api[apiName];
|
||||||
|
|
||||||
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);
|
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);
|
||||||
|
@ -27,7 +27,7 @@ module.exports = async (uid, entity, files) => {
|
|||||||
let tmpModel = modelDef;
|
let tmpModel = modelDef;
|
||||||
let modelUID = uid;
|
let modelUID = uid;
|
||||||
|
|
||||||
for (let i = 0; i < path.length; i++) {
|
for (let i = 0; i < path.length; i += 1) {
|
||||||
if (!tmpModel) return {};
|
if (!tmpModel) return {};
|
||||||
const part = path[i];
|
const part = path[i];
|
||||||
const attr = tmpModel.attributes[part];
|
const attr = tmpModel.attributes[part];
|
||||||
|
@ -26,7 +26,7 @@ module.exports = class WorkerQueue {
|
|||||||
enqueue(payload) {
|
enqueue(payload) {
|
||||||
debug('Enqueue event in worker queue');
|
debug('Enqueue event in worker queue');
|
||||||
if (this.running < this.concurrency) {
|
if (this.running < this.concurrency) {
|
||||||
this.running++;
|
this.running += 1;
|
||||||
this.execute(payload);
|
this.execute(payload);
|
||||||
} else {
|
} else {
|
||||||
this.queue.unshift(payload);
|
this.queue.unshift(payload);
|
||||||
@ -40,7 +40,7 @@ module.exports = class WorkerQueue {
|
|||||||
if (payload) {
|
if (payload) {
|
||||||
this.execute(payload);
|
this.execute(payload);
|
||||||
} else {
|
} else {
|
||||||
this.running--;
|
this.running -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = (path) => {
|
module.exports = (path) => {
|
||||||
if (typeof path !== 'string') throw new Error('admin.url must be a string');
|
let tmpPath = path;
|
||||||
if (path === '' || path === '/') return '/';
|
if (typeof tmpPath !== 'string') throw new Error('admin.url must be a string');
|
||||||
|
if (tmpPath === '' || tmpPath === '/') return '/';
|
||||||
|
|
||||||
if (path[0] != '/') path = `/${path}`;
|
if (tmpPath[0] !== '/') tmpPath = `/${tmpPath}`;
|
||||||
if (path[path.length - 1] != '/') path += '/';
|
if (tmpPath[tmpPath.length - 1] !== '/') tmpPath += '/';
|
||||||
return path;
|
return tmpPath;
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ const getAssociationFromFieldKey = ({ model, field }) => {
|
|||||||
let association;
|
let association;
|
||||||
let attribute;
|
let attribute;
|
||||||
|
|
||||||
for (let i = 0; i < fieldParts.length; i++) {
|
for (let i = 0; i < fieldParts.length; i += 1) {
|
||||||
const part = fieldParts[i];
|
const part = fieldParts[i];
|
||||||
attribute = part;
|
attribute = part;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString
|
|||||||
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
||||||
|
|
||||||
function printNumber(val) {
|
function printNumber(val) {
|
||||||
|
// eslint-disable-next-line eqeqeq
|
||||||
if (val != +val) return 'NaN';
|
if (val != +val) return 'NaN';
|
||||||
const isNegativeZero = val === 0 && 1 / val < 0;
|
const isNegativeZero = val === 0 && 1 / val < 0;
|
||||||
return isNegativeZero ? '-0' : `${val}`;
|
return isNegativeZero ? '-0' : `${val}`;
|
||||||
|
@ -61,7 +61,7 @@ async function askDbInfosAndTest(scope) {
|
|||||||
.then((result) => {
|
.then((result) => {
|
||||||
if (result && result.shouldRetry === true && retries < MAX_RETRIES - 1) {
|
if (result && result.shouldRetry === true && retries < MAX_RETRIES - 1) {
|
||||||
console.log('Retrying...');
|
console.log('Retrying...');
|
||||||
retries++;
|
retries += 1;
|
||||||
return loop();
|
return loop();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -86,7 +86,7 @@ async function askDbInfosAndTest(scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Retrying...');
|
console.log('Retrying...');
|
||||||
retries++;
|
retries += 1;
|
||||||
return loop();
|
return loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,13 @@ module.exports = ({ strapi }) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
registerDoc(doc) {
|
registerDoc(doc) {
|
||||||
|
let registeredDoc = doc;
|
||||||
// parseYaml
|
// parseYaml
|
||||||
if (typeof doc === 'string') {
|
if (typeof doc === 'string') {
|
||||||
doc = require('yaml').parse(doc);
|
registeredDoc = require('yaml').parse(registeredDoc);
|
||||||
}
|
}
|
||||||
// receive an object we can register it directly
|
// receive an object we can register it directly
|
||||||
registeredDocs.push(doc);
|
registeredDocs.push(registeredDoc);
|
||||||
},
|
},
|
||||||
getDocumentationVersion() {
|
getDocumentationVersion() {
|
||||||
return _.get(config, 'info.version');
|
return _.get(config, 'info.version');
|
||||||
|
@ -147,7 +147,7 @@ module.exports = {
|
|||||||
.query('plugin::users-permissions.user')
|
.query('plugin::users-permissions.user')
|
||||||
.findOne({ where: { username } });
|
.findOne({ where: { username } });
|
||||||
|
|
||||||
if (userWithSameUsername && userWithSameUsername.id != id) {
|
if (userWithSameUsername && _.toString(userWithSameUsername.id) !== _.toString(id)) {
|
||||||
throw new ApplicationError('Username already taken');
|
throw new ApplicationError('Username already taken');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ module.exports = {
|
|||||||
.query('plugin::users-permissions.user')
|
.query('plugin::users-permissions.user')
|
||||||
.findOne({ where: { email: _.toLower(email) } });
|
.findOne({ where: { email: _.toLower(email) } });
|
||||||
|
|
||||||
if (userWithSameEmail && userWithSameEmail.id != id) {
|
if (userWithSameEmail && _.toString(userWithSameEmail.id) !== _.toString(id)) {
|
||||||
throw new ApplicationError('Email already taken');
|
throw new ApplicationError('Email already taken');
|
||||||
}
|
}
|
||||||
body.email = _.toLower(body.email);
|
body.email = _.toLower(body.email);
|
||||||
|
@ -105,7 +105,7 @@ module.exports = {
|
|||||||
.query('plugin::users-permissions.user')
|
.query('plugin::users-permissions.user')
|
||||||
.findOne({ where: { username } });
|
.findOne({ where: { username } });
|
||||||
|
|
||||||
if (userWithSameUsername && userWithSameUsername.id != id) {
|
if (userWithSameUsername && _.toString(userWithSameUsername.id) !== _.toString(id)) {
|
||||||
throw new ApplicationError('Username already taken');
|
throw new ApplicationError('Username already taken');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ module.exports = {
|
|||||||
.query('plugin::users-permissions.user')
|
.query('plugin::users-permissions.user')
|
||||||
.findOne({ where: { email: email.toLowerCase() } });
|
.findOne({ where: { email: email.toLowerCase() } });
|
||||||
|
|
||||||
if (userWithSameEmail && userWithSameEmail.id != id) {
|
if (userWithSameEmail && _.toString(userWithSameEmail.id) !== _.toString(id)) {
|
||||||
throw new ApplicationError('Email already taken');
|
throw new ApplicationError('Email already taken');
|
||||||
}
|
}
|
||||||
ctx.request.body.email = ctx.request.body.email.toLowerCase();
|
ctx.request.body.email = ctx.request.body.email.toLowerCase();
|
||||||
|
@ -13,10 +13,10 @@ const printResults = (results) => {
|
|||||||
Object.entries(pkgs).forEach(([packageName, keys]) => {
|
Object.entries(pkgs).forEach(([packageName, keys]) => {
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
console.log(`"${chalk.yellow(value)}" ${packageName} ${chalk.blue(key)}`);
|
console.log(`"${chalk.yellow(value)}" ${packageName} ${chalk.blue(key)}`);
|
||||||
keysCount++;
|
keysCount += 1;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
valuesCount++;
|
valuesCount += 1;
|
||||||
console.log();
|
console.log();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -137,10 +137,10 @@ const merge = async (valuesToMerge) => {
|
|||||||
valueGroup.forEach((keyGroup) => {
|
valueGroup.forEach((keyGroup) => {
|
||||||
updateTranslationFiles(keyGroup, targetKey);
|
updateTranslationFiles(keyGroup, targetKey);
|
||||||
keyGroup.replaceAll(`id: '${targetKey}'`);
|
keyGroup.replaceAll(`id: '${targetKey}'`);
|
||||||
mergedCount++;
|
mergedCount += 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
current++;
|
current += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Merged ${mergedCount} keys`);
|
console.log(`Merged ${mergedCount} keys`);
|
||||||
|
@ -25,7 +25,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
if (req.url == '/spec.yml') {
|
if (req.url === '/spec.yml') {
|
||||||
return fse.createReadStream(openAPISpecPath).pipe(res);
|
return fse.createReadStream(openAPISpecPath).pipe(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ Object.defineProperty(global, 'strapi', {
|
|||||||
strapiInstance = value;
|
strapiInstance = value;
|
||||||
|
|
||||||
strapiInstance.plugin = (name) => strapiInstance.plugins[name];
|
strapiInstance.plugin = (name) => strapiInstance.plugins[name];
|
||||||
_.mapValues(strapi.plugins, (plugin) => {
|
_.mapValues(strapi.plugins, (acc) => {
|
||||||
plugin.controller = (name) => plugin.controllers[name];
|
acc.controller = (name) => acc.controllers[name];
|
||||||
plugin.service = (name) => plugin.services[name];
|
acc.service = (name) => acc.services[name];
|
||||||
plugin.contentType = (name) => plugin.contentTypes[name];
|
acc.contentType = (name) => acc.contentTypes[name];
|
||||||
plugin.policy = (name) => plugin.policies[name];
|
acc.policy = (name) => acc.policies[name];
|
||||||
});
|
});
|
||||||
|
|
||||||
strapiInstance.service = (name = '') => {
|
strapiInstance.service = (name = '') => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user