Allow api to be disabled

This commit is contained in:
斟酌 鵬兄 2022-08-03 15:10:42 +09:00
parent ce1b9b3a0e
commit a95d389cb1

9
api.js
View File

@ -8,7 +8,6 @@ var http = require( "http" );
var conf = cl.load( "config.all" ).botanjs; var conf = cl.load( "config.all" ).botanjs;
var Session = cl.load( "botansx.modular.session" );
var hash = cl.load( "botansx.utils.hash" ); var hash = cl.load( "botansx.utils.hash" );
var rand = cl.load( "botansx.utils.random" ); var rand = cl.load( "botansx.utils.random" );
@ -19,6 +18,7 @@ var BotanJS = function()
this.kv = {}; this.kv = {};
this.embed = {}; this.embed = {};
this._nonce = {}; this._nonce = {};
this.disabled = false;
}; };
util.inherits( BotanJS, events.EventEmitter ); util.inherits( BotanJS, events.EventEmitter );
@ -77,6 +77,12 @@ BotanJS.prototype.compile = function( type )
{ {
var _self = this; var _self = this;
if( this.disabled )
{
_self.emit( "complete" );
return;
}
var j = conf.debug ? [ "Components.Console" ] : []; var j = conf.debug ? [ "Components.Console" ] : [];
for( var i in this.sv ) if( this.sv[ i ] ) j.push( i ); for( var i in this.sv ) if( this.sv[ i ] ) j.push( i );
for( var i in this.kv ) if( this.kv[ i ] ) j.push( i ); for( var i in this.kv ) if( this.kv[ i ] ) j.push( i );
@ -99,6 +105,7 @@ BotanJS.prototype.compile = function( type )
var q = j.join( "," ); var q = j.join( "," );
var lookupKey = hash.md5( q ); var lookupKey = hash.md5( q );
var Session = cl.load( "botansx.modular.session" );
var fastCache = new Session( lookupKey, "BOTAN_JCACHE", true ); var fastCache = new Session( lookupKey, "BOTAN_JCACHE", true );
var deflateComplete = function( err, data ) var deflateComplete = function( err, data )