index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. /* eslint-disable @typescript-eslint/no-this-alias */
  2. import http from 'http';
  3. import path from 'path';
  4. import { createTerminus } from '@godaddy/terminus';
  5. import { initMongooseGlobalSettings, getMongoUri, mongoOptions } from '@growi/core';
  6. import mongoose from 'mongoose';
  7. import pkg from '^/package.json';
  8. import CdnResourcesService from '~/services/cdn-resources-service';
  9. import InterceptorManager from '~/services/interceptor-manager';
  10. import Xss from '~/services/xss';
  11. import loggerFactory from '~/utils/logger';
  12. import { projectRoot } from '~/utils/project-dir-utils';
  13. import Activity from '../models/activity';
  14. import PageRedirect from '../models/page-redirect';
  15. import Tag from '../models/tag';
  16. import UpdatePost from '../models/update-post';
  17. import UserGroup from '../models/user-group';
  18. import AclService from '../service/acl';
  19. import AppService from '../service/app';
  20. import AttachmentService from '../service/attachment';
  21. import ConfigManager from '../service/config-manager';
  22. import { InstallerService } from '../service/installer';
  23. import PageService from '../service/page';
  24. import PageGrantService from '../service/page-grant';
  25. import PageOperationService from '../service/page-operation';
  26. import SearchService from '../service/search';
  27. import { SlackIntegrationService } from '../service/slack-integration';
  28. import { UserNotificationService } from '../service/user-notification';
  29. const logger = loggerFactory('growi:crowi');
  30. const httpErrorHandler = require('../middlewares/http-error-handler');
  31. const models = require('../models');
  32. const PluginService = require('../plugins/plugin.service');
  33. const sep = path.sep;
  34. function Crowi() {
  35. this.version = pkg.version;
  36. this.runtimeVersions = undefined; // initialized by scanRuntimeVersions()
  37. this.publicDir = path.join(projectRoot, 'public') + sep;
  38. this.resourceDir = path.join(projectRoot, 'resource') + sep;
  39. this.localeDir = path.join(this.resourceDir, 'locales') + sep;
  40. this.viewsDir = path.resolve(__dirname, '../views') + sep;
  41. this.tmpDir = path.join(projectRoot, 'tmp') + sep;
  42. this.cacheDir = path.join(this.tmpDir, 'cache');
  43. this.express = null;
  44. this.config = {};
  45. this.configManager = null;
  46. this.s2sMessagingService = null;
  47. this.mailService = null;
  48. this.passportService = null;
  49. this.globalNotificationService = null;
  50. this.userNotificationService = null;
  51. this.xssService = null;
  52. this.aclService = null;
  53. this.appService = null;
  54. this.fileUploadService = null;
  55. this.restQiitaAPIService = null;
  56. this.growiBridgeService = null;
  57. this.exportService = null;
  58. this.importService = null;
  59. this.searchService = null;
  60. this.socketIoService = null;
  61. this.pageService = null;
  62. this.syncPageStatusService = null;
  63. this.cdnResourcesService = new CdnResourcesService();
  64. this.interceptorManager = new InterceptorManager();
  65. this.slackIntegrationService = null;
  66. this.inAppNotificationService = null;
  67. this.activityService = null;
  68. this.commentService = null;
  69. this.xss = new Xss();
  70. this.tokens = null;
  71. this.models = {};
  72. this.env = process.env;
  73. this.node_env = this.env.NODE_ENV || 'development';
  74. this.port = this.env.PORT || 3000;
  75. this.events = {
  76. user: new (require('../events/user'))(this),
  77. page: new (require('../events/page'))(this),
  78. bookmark: new (require('../events/bookmark'))(this),
  79. comment: new (require('../events/comment'))(this),
  80. tag: new (require('../events/tag'))(this),
  81. admin: new (require('../events/admin'))(this),
  82. };
  83. }
  84. Crowi.prototype.init = async function() {
  85. await this.setupDatabase();
  86. await this.setupModels();
  87. await this.setupConfigManager();
  88. await this.setupSessionConfig();
  89. // setup messaging services
  90. await this.setupS2sMessagingService();
  91. await this.setupSocketIoService();
  92. // customizeService depends on AppService and XssService
  93. // passportService depends on appService
  94. // export and import depends on setUpGrowiBridge
  95. await Promise.all([
  96. this.setUpApp(),
  97. this.setUpXss(),
  98. this.setUpGrowiBridge(),
  99. ]);
  100. await Promise.all([
  101. this.scanRuntimeVersions(),
  102. this.setupPassport(),
  103. this.setupSearcher(),
  104. this.setupMailer(),
  105. this.setupSlackIntegrationService(),
  106. this.setupCsrf(),
  107. this.setUpFileUpload(),
  108. this.setUpFileUploaderSwitchService(),
  109. this.setupAttachmentService(),
  110. this.setUpAcl(),
  111. this.setUpCustomize(),
  112. this.setUpRestQiitaAPI(),
  113. this.setupUserGroupService(),
  114. this.setupExport(),
  115. this.setupImport(),
  116. this.setupPageService(),
  117. this.setupInAppNotificationService(),
  118. this.setupActivityService(),
  119. this.setupCommentService(),
  120. this.setupSyncPageStatusService(),
  121. ]);
  122. // globalNotification depends on slack and mailer
  123. await Promise.all([
  124. this.setUpGlobalNotification(),
  125. this.setUpUserNotification(),
  126. ]);
  127. await this.autoInstall();
  128. };
  129. Crowi.prototype.isPageId = function(pageId) {
  130. if (!pageId) {
  131. return false;
  132. }
  133. if (typeof pageId === 'string' && pageId.match(/^[\da-f]{24}$/)) {
  134. return true;
  135. }
  136. return false;
  137. };
  138. Crowi.prototype.setConfig = function(config) {
  139. this.config = config;
  140. };
  141. Crowi.prototype.getConfig = function() {
  142. return this.config;
  143. };
  144. Crowi.prototype.getEnv = function() {
  145. return this.env;
  146. };
  147. // getter/setter of model instance
  148. //
  149. Crowi.prototype.model = function(name, model) {
  150. if (model != null) {
  151. this.models[name] = model;
  152. }
  153. return this.models[name];
  154. };
  155. // getter/setter of event instance
  156. Crowi.prototype.event = function(name, event) {
  157. if (event) {
  158. this.events[name] = event;
  159. }
  160. return this.events[name];
  161. };
  162. Crowi.prototype.setupDatabase = function() {
  163. mongoose.Promise = global.Promise;
  164. // mongoUri = mongodb://user:password@host/dbname
  165. const mongoUri = getMongoUri();
  166. initMongooseGlobalSettings();
  167. return mongoose.connect(mongoUri, mongoOptions);
  168. };
  169. Crowi.prototype.setupSessionConfig = async function() {
  170. const session = require('express-session');
  171. const sessionMaxAge = this.configManager.getConfig('crowi', 'security:sessionMaxAge') || 2592000000; // default: 30days
  172. const redisUrl = this.env.REDISTOGO_URL || this.env.REDIS_URI || this.env.REDIS_URL || null;
  173. const uid = require('uid-safe').sync;
  174. // generate pre-defined uid for healthcheck
  175. const healthcheckUid = uid(24);
  176. const sessionConfig = {
  177. rolling: true,
  178. secret: this.env.SECRET_TOKEN || 'this is default session secret',
  179. resave: false,
  180. saveUninitialized: true,
  181. cookie: {
  182. maxAge: sessionMaxAge,
  183. },
  184. genid(req) {
  185. // return pre-defined uid when healthcheck
  186. if (req.path === '/_api/v3/healthcheck') {
  187. return healthcheckUid;
  188. }
  189. return uid(24);
  190. },
  191. };
  192. if (this.env.SESSION_NAME) {
  193. sessionConfig.name = this.env.SESSION_NAME;
  194. }
  195. // use Redis for session store
  196. if (redisUrl) {
  197. const redis = require('redis');
  198. const redisClient = redis.createClient({ url: redisUrl });
  199. const RedisStore = require('connect-redis')(session);
  200. sessionConfig.store = new RedisStore({ client: redisClient });
  201. }
  202. // use MongoDB for session store
  203. else {
  204. const MongoStore = require('connect-mongo');
  205. sessionConfig.store = MongoStore.create({ client: mongoose.connection.getClient() });
  206. }
  207. this.sessionConfig = sessionConfig;
  208. };
  209. Crowi.prototype.setupConfigManager = async function() {
  210. this.configManager = new ConfigManager();
  211. return this.configManager.loadConfigs();
  212. };
  213. Crowi.prototype.setupS2sMessagingService = async function() {
  214. const s2sMessagingService = require('../service/s2s-messaging')(this);
  215. if (s2sMessagingService != null) {
  216. s2sMessagingService.subscribe();
  217. this.configManager.setS2sMessagingService(s2sMessagingService);
  218. // add as a message handler
  219. s2sMessagingService.addMessageHandler(this.configManager);
  220. this.s2sMessagingService = s2sMessagingService;
  221. }
  222. };
  223. Crowi.prototype.setupSocketIoService = async function() {
  224. const SocketIoService = require('../service/socket-io');
  225. if (this.socketIoService == null) {
  226. this.socketIoService = new SocketIoService(this);
  227. }
  228. };
  229. Crowi.prototype.setupModels = async function() {
  230. let allModels = {};
  231. // include models that dependent on crowi
  232. allModels = models;
  233. // include models that independent from crowi
  234. allModels.Activity = Activity;
  235. allModels.Tag = Tag;
  236. allModels.UserGroup = UserGroup;
  237. allModels.PageRedirect = PageRedirect;
  238. Object.keys(allModels).forEach((key) => {
  239. return this.model(key, models[key](this));
  240. });
  241. };
  242. Crowi.prototype.scanRuntimeVersions = async function() {
  243. const self = this;
  244. const check = require('check-node-version');
  245. return new Promise((resolve, reject) => {
  246. check((err, result) => {
  247. if (err) {
  248. reject(err);
  249. }
  250. self.runtimeVersions = result;
  251. resolve();
  252. });
  253. });
  254. };
  255. Crowi.prototype.getSlack = function() {
  256. return this.slack;
  257. };
  258. Crowi.prototype.getSlackLegacy = function() {
  259. return this.slackLegacy;
  260. };
  261. Crowi.prototype.getInterceptorManager = function() {
  262. return this.interceptorManager;
  263. };
  264. Crowi.prototype.getGlobalNotificationService = function() {
  265. return this.globalNotificationService;
  266. };
  267. Crowi.prototype.getUserNotificationService = function() {
  268. return this.userNotificationService;
  269. };
  270. Crowi.prototype.getRestQiitaAPIService = function() {
  271. return this.restQiitaAPIService;
  272. };
  273. Crowi.prototype.setupPassport = async function() {
  274. logger.debug('Passport is enabled');
  275. // initialize service
  276. const PassportService = require('../service/passport');
  277. if (this.passportService == null) {
  278. this.passportService = new PassportService(this);
  279. }
  280. this.passportService.setupSerializer();
  281. // setup strategies
  282. try {
  283. this.passportService.setupStrategyById('local');
  284. this.passportService.setupStrategyById('ldap');
  285. this.passportService.setupStrategyById('saml');
  286. this.passportService.setupStrategyById('oidc');
  287. this.passportService.setupStrategyById('basic');
  288. this.passportService.setupStrategyById('google');
  289. this.passportService.setupStrategyById('github');
  290. this.passportService.setupStrategyById('twitter');
  291. }
  292. catch (err) {
  293. logger.error(err);
  294. }
  295. // add as a message handler
  296. if (this.s2sMessagingService != null) {
  297. this.s2sMessagingService.addMessageHandler(this.passportService);
  298. }
  299. return Promise.resolve();
  300. };
  301. Crowi.prototype.setupSearcher = async function() {
  302. this.searchService = new SearchService(this);
  303. };
  304. Crowi.prototype.setupMailer = async function() {
  305. const MailService = require('~/server/service/mail');
  306. this.mailService = new MailService(this);
  307. // add as a message handler
  308. if (this.s2sMessagingService != null) {
  309. this.s2sMessagingService.addMessageHandler(this.mailService);
  310. }
  311. };
  312. Crowi.prototype.setupCsrf = async function() {
  313. const Tokens = require('csrf');
  314. this.tokens = new Tokens();
  315. return Promise.resolve();
  316. };
  317. Crowi.prototype.autoInstall = function() {
  318. const isInstalled = this.configManager.getConfig('crowi', 'app:installed');
  319. const username = this.configManager.getConfig('crowi', 'autoInstall:adminUsername');
  320. if (isInstalled || username == null) {
  321. return;
  322. }
  323. logger.info('Start automatic installation');
  324. const firstAdminUserToSave = {
  325. username,
  326. name: this.configManager.getConfig('crowi', 'autoInstall:adminName'),
  327. email: this.configManager.getConfig('crowi', 'autoInstall:adminEmail'),
  328. password: this.configManager.getConfig('crowi', 'autoInstall:adminPassword'),
  329. admin: true,
  330. };
  331. const globalLang = this.configManager.getConfig('crowi', 'autoInstall:globalLang');
  332. const serverDate = this.configManager.getConfig('crowi', 'autoInstall:serverDate');
  333. const installerService = new InstallerService(this);
  334. try {
  335. installerService.install(firstAdminUserToSave, globalLang ?? 'en_US', serverDate);
  336. }
  337. catch (err) {
  338. logger.warn('Automatic installation failed.', err);
  339. }
  340. };
  341. Crowi.prototype.getTokens = function() {
  342. return this.tokens;
  343. };
  344. Crowi.prototype.start = async function() {
  345. // init CrowiDev
  346. if (this.node_env === 'development') {
  347. const CrowiDev = require('./dev');
  348. this.crowiDev = new CrowiDev(this);
  349. this.crowiDev.init();
  350. }
  351. await this.init();
  352. await this.buildServer();
  353. const { express, configManager } = this;
  354. // setup plugins
  355. this.pluginService = new PluginService(this, express);
  356. await this.pluginService.autoDetectAndLoadPlugins();
  357. const app = (this.node_env === 'development') ? this.crowiDev.setupServer(express) : express;
  358. const httpServer = http.createServer(app);
  359. // setup terminus
  360. this.setupTerminus(httpServer);
  361. // attach to socket.io
  362. this.socketIoService.attachServer(httpServer);
  363. // listen
  364. const serverListening = httpServer.listen(this.port, () => {
  365. logger.info(`[${this.node_env}] Express server is listening on port ${this.port}`);
  366. if (this.node_env === 'development') {
  367. this.crowiDev.setupExpressAfterListening(express);
  368. }
  369. });
  370. // listen for promster
  371. if (configManager.getConfig('crowi', 'promster:isEnabled')) {
  372. const { createServer } = require('@promster/server');
  373. const promsterPort = configManager.getConfig('crowi', 'promster:port');
  374. createServer({ port: promsterPort }).then(() => {
  375. logger.info(`[${this.node_env}] Promster server is listening on port ${promsterPort}`);
  376. });
  377. }
  378. // setup Express Routes
  379. this.setupRoutesAtLast();
  380. // setup Global Error Handlers
  381. this.setupGlobalErrorHandlers();
  382. return serverListening;
  383. };
  384. Crowi.prototype.buildServer = async function() {
  385. const env = this.node_env;
  386. const express = require('express')();
  387. require('./express-init')(this, express);
  388. // use bunyan
  389. if (env === 'production') {
  390. const expressBunyanLogger = require('express-bunyan-logger');
  391. const logger = loggerFactory('express');
  392. express.use(expressBunyanLogger({
  393. logger,
  394. excludes: ['*'],
  395. }));
  396. }
  397. // use morgan
  398. else {
  399. const morgan = require('morgan');
  400. express.use(morgan('dev'));
  401. }
  402. this.express = express;
  403. };
  404. Crowi.prototype.setupTerminus = function(server) {
  405. createTerminus(server, {
  406. signals: ['SIGINT', 'SIGTERM'],
  407. onSignal: async() => {
  408. logger.info('Server is starting cleanup');
  409. await mongoose.disconnect();
  410. return;
  411. },
  412. onShutdown: async() => {
  413. logger.info('Cleanup finished, server is shutting down');
  414. },
  415. });
  416. };
  417. /**
  418. * setup Express Routes
  419. * !! this must be at last because it includes '/*' route !!
  420. */
  421. Crowi.prototype.setupRoutesAtLast = function() {
  422. require('../routes')(this, this.express);
  423. };
  424. /**
  425. * setup global error handlers
  426. * !! this must be after the Routes setup !!
  427. */
  428. Crowi.prototype.setupGlobalErrorHandlers = function() {
  429. this.express.use(httpErrorHandler);
  430. };
  431. /**
  432. * require API for plugins
  433. *
  434. * @param {string} modulePath relative path from /lib/crowi/index.js
  435. * @return {module}
  436. *
  437. * @memberof Crowi
  438. */
  439. Crowi.prototype.require = function(modulePath) {
  440. return require(modulePath);
  441. };
  442. /**
  443. * setup GlobalNotificationService
  444. */
  445. Crowi.prototype.setUpGlobalNotification = async function() {
  446. const GlobalNotificationService = require('../service/global-notification');
  447. if (this.globalNotificationService == null) {
  448. this.globalNotificationService = new GlobalNotificationService(this);
  449. }
  450. };
  451. /**
  452. * setup UserNotificationService
  453. */
  454. Crowi.prototype.setUpUserNotification = async function() {
  455. if (this.userNotificationService == null) {
  456. this.userNotificationService = new UserNotificationService(this);
  457. }
  458. };
  459. /**
  460. * setup XssService
  461. */
  462. Crowi.prototype.setUpXss = async function() {
  463. const XssService = require('../service/xss');
  464. if (this.xssService == null) {
  465. this.xssService = new XssService(this.configManager);
  466. }
  467. };
  468. /**
  469. * setup AclService
  470. */
  471. Crowi.prototype.setUpAcl = async function() {
  472. if (this.aclService == null) {
  473. this.aclService = new AclService(this.configManager);
  474. }
  475. };
  476. /**
  477. * setup CustomizeService
  478. */
  479. Crowi.prototype.setUpCustomize = async function() {
  480. const CustomizeService = require('../service/customize');
  481. if (this.customizeService == null) {
  482. this.customizeService = new CustomizeService(this);
  483. this.customizeService.initCustomCss();
  484. this.customizeService.initCustomTitle();
  485. // add as a message handler
  486. if (this.s2sMessagingService != null) {
  487. this.s2sMessagingService.addMessageHandler(this.customizeService);
  488. }
  489. }
  490. };
  491. /**
  492. * setup AppService
  493. */
  494. Crowi.prototype.setUpApp = async function() {
  495. if (this.appService == null) {
  496. this.appService = new AppService(this);
  497. // add as a message handler
  498. const isInstalled = this.configManager.getConfig('crowi', 'app:installed');
  499. if (this.s2sMessagingService != null && !isInstalled) {
  500. this.s2sMessagingService.addMessageHandler(this.appService);
  501. }
  502. }
  503. };
  504. /**
  505. * setup FileUploadService
  506. */
  507. Crowi.prototype.setUpFileUpload = async function(isForceUpdate = false) {
  508. if (this.fileUploadService == null || isForceUpdate) {
  509. this.fileUploadService = require('../service/file-uploader')(this);
  510. }
  511. };
  512. /**
  513. * setup FileUploaderSwitchService
  514. */
  515. Crowi.prototype.setUpFileUploaderSwitchService = async function() {
  516. const FileUploaderSwitchService = require('../service/file-uploader-switch');
  517. this.fileUploaderSwitchService = new FileUploaderSwitchService(this);
  518. // add as a message handler
  519. if (this.s2sMessagingService != null) {
  520. this.s2sMessagingService.addMessageHandler(this.fileUploaderSwitchService);
  521. }
  522. };
  523. /**
  524. * setup AttachmentService
  525. */
  526. Crowi.prototype.setupAttachmentService = async function() {
  527. if (this.attachmentService == null) {
  528. this.attachmentService = new AttachmentService(this);
  529. }
  530. };
  531. /**
  532. * setup RestQiitaAPIService
  533. */
  534. Crowi.prototype.setUpRestQiitaAPI = async function() {
  535. const RestQiitaAPIService = require('../service/rest-qiita-API');
  536. if (this.restQiitaAPIService == null) {
  537. this.restQiitaAPIService = new RestQiitaAPIService(this);
  538. }
  539. };
  540. Crowi.prototype.setupUserGroupService = async function() {
  541. const UserGroupService = require('../service/user-group');
  542. if (this.userGroupService == null) {
  543. this.userGroupService = new UserGroupService(this);
  544. return this.userGroupService.init();
  545. }
  546. };
  547. Crowi.prototype.setUpGrowiBridge = async function() {
  548. const GrowiBridgeService = require('../service/growi-bridge');
  549. if (this.growiBridgeService == null) {
  550. this.growiBridgeService = new GrowiBridgeService(this);
  551. }
  552. };
  553. Crowi.prototype.setupExport = async function() {
  554. const ExportService = require('../service/export');
  555. if (this.exportService == null) {
  556. this.exportService = new ExportService(this);
  557. }
  558. };
  559. Crowi.prototype.setupImport = async function() {
  560. const ImportService = require('../service/import');
  561. if (this.importService == null) {
  562. this.importService = new ImportService(this);
  563. }
  564. };
  565. Crowi.prototype.setupPageService = async function() {
  566. if (this.pageService == null) {
  567. this.pageService = new PageService(this);
  568. }
  569. if (this.pageGrantService == null) {
  570. this.pageGrantService = new PageGrantService(this);
  571. }
  572. if (this.pageOperationService == null) {
  573. this.pageOperationService = new PageOperationService(this);
  574. // TODO: Remove this code when resuming feature is implemented
  575. await this.pageOperationService.init();
  576. }
  577. };
  578. Crowi.prototype.setupInAppNotificationService = async function() {
  579. const InAppNotificationService = require('../service/in-app-notification');
  580. if (this.inAppNotificationService == null) {
  581. this.inAppNotificationService = new InAppNotificationService(this);
  582. }
  583. };
  584. Crowi.prototype.setupActivityService = async function() {
  585. const ActivityService = require('../service/activity');
  586. if (this.activityService == null) {
  587. this.activityService = new ActivityService(this);
  588. }
  589. };
  590. Crowi.prototype.setupCommentService = async function() {
  591. const CommentService = require('../service/comment');
  592. if (this.commentService == null) {
  593. this.commentService = new CommentService(this);
  594. }
  595. };
  596. Crowi.prototype.setupSyncPageStatusService = async function() {
  597. const SyncPageStatusService = require('../service/system-events/sync-page-status');
  598. if (this.syncPageStatusService == null) {
  599. this.syncPageStatusService = new SyncPageStatusService(this, this.s2sMessagingService, this.socketIoService);
  600. // add as a message handler
  601. if (this.s2sMessagingService != null) {
  602. this.s2sMessagingService.addMessageHandler(this.syncPageStatusService);
  603. }
  604. }
  605. };
  606. Crowi.prototype.setupSlackIntegrationService = async function() {
  607. if (this.slackIntegrationService == null) {
  608. this.slackIntegrationService = new SlackIntegrationService(this);
  609. }
  610. // add as a message handler
  611. if (this.s2sMessagingService != null) {
  612. this.s2sMessagingService.addMessageHandler(this.slackIntegrationService);
  613. }
  614. };
  615. export default Crowi;