Fix Strapi prototype

This commit is contained in:
loicsaintroch 2015-12-02 16:52:52 +01:00
parent 0125c4c261
commit b9f14866a8
2 changed files with 20 additions and 2 deletions

View File

@ -36,6 +36,17 @@ function Strapi() {
// Mixin support for `Strapi.prototype.after()`.
mixinAfter(this);
// Bind `this` context for all `Strapi.prototype.*` methods.
this.load = this.load.bind(this);
this.start = this.start.bind(this);
this.stop = this.stop.bind(this);
this.restart = this.restart.bind(this);
this.initialize = this.initialize.bind(this);
this.exposeGlobals = this.exposeGlobals.bind(this);
this.runBootstrap = this.runBootstrap.bind(this);
this.isLocalStrapiValid = this.isLocalStrapiValid.bind(this);
this.isStrapiAppSync = this.isStrapiAppSync.bind(this);
// Expose `koa`.
this.server = require('koa');
this.app = require('koa')();

View File

@ -12,6 +12,13 @@ const Strapi = require('./Strapi');
* (maintains backwards compatibility with constructor usage).
*/
module.exports = function () {
module.exports = strapiFactory;
function strapiFactory() {
return new Strapi();
};
}
// Backwards compatibility for Strapi singleton usage.
const singleton = strapiFactory();
strapiFactory.isLocalStrapiValid = singleton.isLocalStrapiValid.bind(singleton);
strapiFactory.isStrapiAppSync = singleton.isStrapiAppSync.bind(singleton);