Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
/**
* Module dependencies
*/
// Public node modules.
const _ = require('lodash');
// Strapi utilities.
const finder = require('strapi-utils').finder;
const regex = require('strapi-utils').regex;
const policyUtils = require('strapi-utils').policy;
module.exports = strapi =>
function routerChecker(value, endpoint, plugin) {
const route = regex.detectRoute(endpoint);
// Define controller and action names.
const [controllerName, actionName] = _.trim(value.handler).split('.');
const controllerKey = _.toLower(controllerName);
let controller;
if (plugin) {
controller = strapi.plugins[plugin].controllers[controllerKey];
} else {
controller =
strapi.controllers[controllerKey] ||
/**
* GraphQL.js service
*
* @description: A set of functions similar to controller's actions to avoid code duplication.
*/
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const pluralize = require('pluralize');
const graphql = require('graphql');
const { makeExecutableSchema } = require('graphql-tools');
const GraphQLJSON = require('graphql-type-json');
const GraphQLDateTime = require('graphql-type-datetime');
const policyUtils = require('strapi-utils').policy;
module.exports = {
/**
* Receive an Object and return a string which is following the GraphQL specs.
*
* @return String
*/
formatGQL: function (fields, description = {}, model = {}, type = 'field') {
const typeFields = JSON.stringify(fields, null, 2).replace(/['",]+/g, '');
const lines = typeFields.split('\n');
// Try to add description for field.
if (type === 'field') {
return lines
'use strict';
/**
* Mutation.js service
*
* @description: A set of functions similar to controller's actions to avoid code duplication.
*/
const _ = require('lodash');
const pluralize = require('pluralize');
const compose = require('koa-compose');
const policyUtils = require('strapi-utils').policy;
const Query = require('./Query.js');
module.exports = {
/**
* Execute policies before the specified resolver.
*
* @return Promise or Error.
*/
composeMutationResolver: function({ _schema, plugin, name, action }) {
// Extract custom resolver or type description.
const { resolver: handler = {} } = _schema;
let queryName;
if (_.has(handler, `Mutation.${action}`)) {
queryName = action;
'use strict';
/**
* Query.js service
*
* @description: A set of functions similar to controller's actions to avoid code duplication.
*/
const _ = require('lodash');
const pluralize = require('pluralize');
const policyUtils = require('strapi-utils').policy;
module.exports = {
/**
* Convert parameters to valid filters parameters.
*
* @return Object
*/
convertToParams: params => {
return Object.keys(params).reduce((acc, current) => {
return Object.assign(acc, {
[`_${current}`]: params[current],
});
}, {});
},
'use strict';
/**
* Query.js service
*
* @description: A set of functions similar to controller's actions to avoid code duplication.
*/
const _ = require('lodash');
const pluralize = require('pluralize');
const policyUtils = require('strapi-utils').policy;
const compose = require('koa-compose');
module.exports = {
/**
* Convert parameters to valid filters parameters.
*
* @return Object
*/
convertToParams: params => {
return Object.keys(params).reduce((acc, current) => {
const key = current === 'id' ? 'id' : `_${current}`;
acc[key] = params[current];
return acc;
}, {});
},