From 5d31fffc321717afb6c0cbb0f5dab9bd8f844eda Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 7 Mar 2023 13:04:37 +0300 Subject: Conditional modules initialization --- vnext/server/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'vnext/server/index.js') diff --git a/vnext/server/index.js b/vnext/server/index.js index b4c637bf..5bfa9070 100644 --- a/vnext/server/index.js +++ b/vnext/server/index.js @@ -10,11 +10,9 @@ import event from './middleware/event'; import oembed from './middleware/oembed'; import urlExpand from './middleware/urlexpand'; -const bot_token = config.get('service.durov.token'); - const PORT = 8081; import path from 'path'; -import { webhook } from './durov'; +import { webhook, webhookPath } from './durov'; // initialize the application and create the routes const app = express(); @@ -25,7 +23,11 @@ const router = express.Router(); router.post('/api/sender', event); router.get('/api/oembed', oembed); router.get('/api/urlexpand', urlExpand); -router.post(`/api/${bot_token}`, webhook); + +const durov_webhook = webhookPath(); +if (durov_webhook) { + router.post(`/api/${durov_webhook}`, webhook); +} router.use('^/$', serverRenderer); const STATIC_ROOT = config.get('service.static_root') || path.resolve(__dirname, 'public'); -- cgit v1.2.3