Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const generateTestApp = async ({ appName, database }) => {
const scope = {
database: {
settings: database,
options: {},
},
rootPath: path.resolve(appName),
name: appName,
// disable quickstart run app after creation
runQuickstartApp: false,
// use pacakge version as strapiVersion (all packages have the same version);
strapiVersion: require('strapi/package.json').version,
debug: false,
quick: false,
uuid: undefined,
deviceId: null,
// use yarn if available and --use-npm isn't true
useYarn: true,
installDependencies: false,
strapiDependencies: [
'strapi',
'strapi-admin',
'strapi-utils',
'strapi-plugin-content-type-builder',
'strapi-plugin-content-manager',
'strapi-plugin-users-permissions',
'strapi-plugin-email',
'strapi-plugin-upload',
fetchLatest: (collectionIdentity, collection, criteria) => {
const filters = _.omit(helpers.handleFilters(criteria), value => {
return _.isUndefined(value) || _.isNumber(value) ? _.isNull(value) : _.isEmpty(value);
});
// Handle filters
filters.orderBy = 'createdAt DESC';
filters.limit = filters.count;
delete filters.count;
return collection.forge(criteria)
.query(filters)
.fetchAll({withRelated: helpers.getAssociationsByIdentity(collectionIdentity)})
.then(data => data.toJSON() || data);
},
// (should work without JS (no interaction but ok visuals))
// Front:
// preview hover links (svg icons)
// conditionnal infos in popup
// Requirements list for submission
// max img size & img resolution?
// next / prev arrows in popup
// better animations (cubic beziers anims, xbox style)
strapi.start();
_.forEach(definition.attributes, function (details, name) {
const verbose = _.get(utilsModels.getNature(details, name), 'verbose') || '';
// Build associations key
if (!_.isEmpty(verbose)) {
utilsModels.defineAssociations(globalName, definition, details, name);
}
switch (verbose) {
case 'hasOne':
const FK = _.findKey(strapi.models[details.model].attributes, function (details) {
if (details.hasOwnProperty('model') && details.model === model && details.hasOwnProperty('via') && details.via === name) {
return details;
}
});
loadedModel[name] = function () {
return this.hasOne(global[_.capitalize(details.model)], FK);
};
break;
case 'hasMany':
_.forEach(definition.attributes, function (details, name) {
const verbose = _.get(utilsModels.getNature(details, name), 'verbose') || '';
// Build associations key
if (!_.isEmpty(verbose)) {
utilsModels.defineAssociations(globalName, definition, details, name);
}
switch (verbose) {
case 'hasOne':
const FK = _.findKey(strapi.models[details.model].attributes, function (details) {
if (details.hasOwnProperty('model') && details.model === model && details.hasOwnProperty('via') && details.via === name) {
return details;
}
});
loadedModel[name] = function () {
return this.hasOne(global[_.capitalize(details.model)], FK);
fetchAll: (collectionIdentity, collection, criteria) => {
const filters = _.omit(helpers.handleFilters(criteria), value => {
return _.isUndefined(value) || _.isNumber(value) ? _.isNull(value) : _.isEmpty(value);
});
return collection.forge()
.query(filters)
.fetchAll({withRelated: helpers.getAssociationsByIdentity(collectionIdentity)})
.then(data => data.toJSON() || data);
},
/**
* Use `server.js` to run your application without `$ strapi start`.
* To start the server, run: `$ npm start`.
*
* This is handy in situations where the Strapi CLI is not relevant or useful.
*/
const strapi = require('strapi');
strapi.start();
(() => {
const strapi = require('strapi');
strapi.start();
})();
(() => {
const strapi = require('strapi');
strapi.start();
})();
(() => {
const strapi = require('strapi');
strapi.start();
})();