-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
60 lines (49 loc) · 2.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* @license
* Copyright 2019-2020 CERN and copyright holders of ALICE O2.
* See http://alice-o2.web.cern.ch/copyright for details of the copyright holders.
* All rights not expressly granted are reserved.
*
* This software is distributed under the terms of the GNU General Public
* License v3 (GPL Version 3), copied verbatim in the file "COPYING".
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/
import { LogManager, HttpServer, WebSocket } from '@aliceo2/web-ui';
const logger = LogManager.getLogger(`${process.env.npm_config_log_label ?? 'qcg'}/index`);
import path from 'path';
import { setup } from './lib/api.js';
// Reading config file
import { config } from './lib/config/configProvider.js';
import { buildPublicConfig } from './lib/config/publicConfigProvider.js';
// Quick check config at start
if (config.http.tls) {
logger.info(`HTTPS endpoint: https://${config.http.hostname}:${config.http.portSecure}`);
}
logger.info(`HTTP endpoint: http://${config.http.hostname}:${config.http.port}`);
if (typeof config.demoData != 'undefined' && config.demoData) {
logger.info('Using demo data');
} else {
config.demoData = false;
}
buildPublicConfig(config);
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
// Start servers
const http = new HttpServer(config.http, config.jwt, config.openId);
http.addStaticPath(path.join(__dirname, 'common'));
http.addStaticPath(path.join(__dirname, 'public'));
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const pathName = require.resolve('jsroot');
http.addStaticPath(path.join(pathName, '../..'), 'jsroot');
const ws = new WebSocket(http);
if (process.env.NODE_ENV === 'test') {
// Initialize nock for CCDB if we are in test environment
const { initializeNockForCcdb } = await import('./test/setup/testSetupForCcdb.js');
initializeNockForCcdb();
}
setup(http, ws);