-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
34 lines (29 loc) · 1.02 KB
/
server.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
require('dotenv').config();
const { BridgeCore } = require('fcecom-bridge-commons');
const logger = require('./src/utils/logger');
const path = require('path');
const LOGGING_NAME = 'server';
// Validate configuration
const propertiesToCheck = ['GRAPHQL_URL', 'API_BASE_URL', 'ACCESS_TOKEN'];
for (const propertyName of propertiesToCheck) {
if (typeof process.env[propertyName] === 'undefined') {
logger.logError(LOGGING_NAME, `Configuration for '${propertyName}' is missing`);
process.exit(1);
}
}
const { BRIDGE_AUTH_USERNAME, BRIDGE_AUTH_PASSWORD, CONN_MODE, SSL_KEY, SSL_CERT, LOG_LEVEL } = process.env;
const port = process.env.NODE_PORT || process.env.PORT || 3000;
BridgeCore({
username: BRIDGE_AUTH_USERNAME,
password: BRIDGE_AUTH_PASSWORD,
servicesDir: path.join(process.cwd(), './src/service'),
port: port,
logLevel: LOG_LEVEL,
features: {
contentPages: true,
categoryTree: true
},
useSsl: CONN_MODE === 'HTTPS',
sslCert: SSL_CERT,
sslKey: SSL_KEY
});