-
Notifications
You must be signed in to change notification settings - Fork 335
/
config.js
68 lines (54 loc) · 1.66 KB
/
config.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
61
62
63
64
65
66
67
68
//'use strict';
const dotenv = require('dotenv');
const assert = require('assert');
const { Sequelize } = require('sequelize');
const database_config = JSON.parse(JSON.stringify(require('./config/config.json')));
dotenv.config();
const is_production = process.env.PRODUCTION === 'true';
if (is_production) {
database_config.development.logging = false;
}
let sequelize = new Sequelize(database_config.development);
(async () => {
try {
await sequelize.authenticate();
console.log('Connection has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error);
}
})();
const {
PORT,
HOST,
HOST_SSL,
TOKEN,
HTTPS,
VERSION,
COMPANY,
LOGO,
START_ALL_SESSIONS,
FORCE_CONNECTION_USE_HERE,
CORS_ORIGIN,
TIME_TYPING
} = process.env;
assert(PORT, 'PORT is required, please set the PORT variable value in the .env file');
assert(TOKEN, 'TOKEN is required, please set the ENGINE variable value in the .env file');
assert(CORS_ORIGIN, 'CORS_ORIGIN is required, please set the CORS_ORIGIN variable value in the .env file');
module.exports = {
port: PORT,
host: "",
host_ssl: HOST_SSL ? HOST_SSL : `${HOST}:${PORT}`,
token: TOKEN,
https: HTTPS,
version: VERSION,
company: COMPANY ? COMPANY : "myzap",
logo: LOGO != "" ? LOGO : "https://upload.wikimedia.org/wikipedia/commons/f/f7/WhatsApp_logo.svg",
ssl_key_path: "",
ssl_cert_path: "",
start_all_sessions: START_ALL_SESSIONS,
useHere: FORCE_CONNECTION_USE_HERE,
device_name: "",
cors_origin: CORS_ORIGIN,
time_typing: TIME_TYPING,
sequelize
}