From a95d389cb140241c47158c2403191ddff5e9ecea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Wed, 3 Aug 2022 15:10:42 +0900 Subject: [PATCH] Allow api to be disabled --- api.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api.js b/api.js index 5da33cc..baa1ef4 100644 --- a/api.js +++ b/api.js @@ -8,7 +8,6 @@ var http = require( "http" ); var conf = cl.load( "config.all" ).botanjs; -var Session = cl.load( "botansx.modular.session" ); var hash = cl.load( "botansx.utils.hash" ); var rand = cl.load( "botansx.utils.random" ); @@ -19,6 +18,7 @@ var BotanJS = function() this.kv = {}; this.embed = {}; this._nonce = {}; + this.disabled = false; }; util.inherits( BotanJS, events.EventEmitter ); @@ -77,6 +77,12 @@ BotanJS.prototype.compile = function( type ) { var _self = this; + if( this.disabled ) + { + _self.emit( "complete" ); + return; + } + var j = conf.debug ? [ "Components.Console" ] : []; 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 ); @@ -99,6 +105,7 @@ BotanJS.prototype.compile = function( type ) var q = j.join( "," ); var lookupKey = hash.md5( q ); + var Session = cl.load( "botansx.modular.session" ); var fastCache = new Session( lookupKey, "BOTAN_JCACHE", true ); var deflateComplete = function( err, data )