mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-03 19:36:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			770 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			770 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict';
 | 
						|
 | 
						|
const _ = require('lodash');
 | 
						|
 | 
						|
// TODO: remove this tmp fix and migrate tests
 | 
						|
let strapiInstance;
 | 
						|
Object.defineProperty(global, 'strapi', {
 | 
						|
  get() {
 | 
						|
    return strapiInstance;
 | 
						|
  },
 | 
						|
  set(value) {
 | 
						|
    strapiInstance = value;
 | 
						|
 | 
						|
    strapiInstance.plugin = name => strapiInstance.plugins[name];
 | 
						|
    _.mapValues(strapi.plugins, plugin => {
 | 
						|
      plugin.controller = name => plugin.controllers[name];
 | 
						|
      plugin.service = name => plugin.services[name];
 | 
						|
      plugin.contentType = name => plugin.contentTypes[name];
 | 
						|
      plugin.policy = name => plugin.policies[name];
 | 
						|
    });
 | 
						|
 | 
						|
    strapiInstance.service = (name = '') => {
 | 
						|
      if (name.startsWith('admin::')) {
 | 
						|
        return strapiInstance.admin.services[name.split('admin::')[1]];
 | 
						|
      }
 | 
						|
    };
 | 
						|
  },
 | 
						|
});
 |