-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
141 lines (127 loc) · 4.18 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
* Klayrhq/klayrservice
* Copyright © 2021 Lisk Foundation
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
* no part of this software, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*
* Removal or modification of this copyright notice is prohibited.
*
*/
const packageJson = require('./package.json');
const config = {};
// Moleculer broker config
config.transporter = process.env.SERVICE_BROKER || 'redis://klayr:password@127.0.0.1:6379/0';
config.brokerTimeout = Number(process.env.SERVICE_BROKER_TIMEOUT) || 10; // in seconds
/**
* External endpoints
*/
config.endpoints = {};
config.endpoints.redis =
process.env.SERVICE_EXPORT_REDIS || 'redis://klayr:password@127.0.0.1:6379/3';
config.endpoints.volatileRedis =
process.env.SERVICE_EXPORT_REDIS_VOLATILE || 'redis://klayr:password@127.0.0.1:6379/4';
// Logging
config.log = {
name: packageJson.name,
version: packageJson.version,
};
/**
* log.level - Limits the importance of log messages for console and stdout outputs
* One fo the following in that order:
* TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK
*/
config.log.level = process.env.SERVICE_LOG_LEVEL || 'info';
/*
* True / False outputs
* log.console - Plain JavaScript console.log() output
* log.stdout - Writes directly to stdout
*/
config.log.console = process.env.SERVICE_LOG_CONSOLE || 'false';
config.log.stdout = process.env.SERVICE_LOG_STDOUT || 'true';
/*
* Configurable outputs
* log.file - outputs to a file (ie. ./logs/app.log)
* log.gelf - Writes to GELF-compatible socket (ie. 127.0.0.1:12201/udp)
*/
config.log.gelf = process.env.SERVICE_LOG_GELF || 'false';
config.log.file = process.env.SERVICE_LOG_FILE || 'false';
// Set docker host if running inside the container
config.log.docker_host = process.env.DOCKER_HOST || 'local';
// CSV output
config.excel = {};
config.excel.delimiter = ';';
config.excel.dateFormat = 'YYYY-MM-DD';
config.excel.timeFormat = 'hh:mm:ss';
config.excel.baseURL = '/api/v3/export/download';
config.excel.sheets = {
TRANSACTION_HISTORY: 'Transaction History',
METADATA: 'Metadata',
};
/**
* Message queue options
*/
config.queue = {
scheduleTransactionExport: {
name: 'ScheduleTransactionExportQueue',
concurrency: 10,
options: {
defaultJobOptions: {
attempts: 5,
timeout: 5 * 60 * 1000, // millisecs
backoff: {
type: 'exponential',
delay: 1 * 60 * 1000, // millisecs
},
removeOnComplete: true,
removeOnFail: true,
stackTraceLimit: 0,
},
},
},
defaults: {
jobOptions: {
attempts: 5,
timeout: 5 * 60 * 1000, // millisecs
removeOnComplete: true,
removeOnFail: true,
stackTraceLimit: 0,
},
settings: {},
},
};
// CSV cache config
config.cache = {};
config.cache.partials = {
driver: 'filesystem', // Accepted values: ['filesystem', 's3-minio']
dirPath: process.env.SERVICE_EXPORT_PARTIALS || './data/partials',
retentionInDays: 30,
s3: { bucketName: process.env.EXPORT_S3_BUCKET_NAME_PARTIALS || 'partials' },
};
config.cache.exports = {
driver: 'filesystem', // Accepted values: ['filesystem', 's3-minio']
dirPath: process.env.SERVICE_EXPORT_STATIC || './data/static',
retentionInDays: 30,
s3: { bucketName: process.env.EXPORT_S3_BUCKET_NAME_EXPORTS || 'exports' },
};
// Amazon S3 config
config.s3 = {};
config.s3.endPoint = process.env.EXPORT_S3_ENDPOINT || 's3.amazonaws.com'; // Optional
config.s3.accessKey = process.env.EXPORT_S3_ACCESS_KEY;
config.s3.secretKey = process.env.EXPORT_S3_SECRET_KEY; // Optional
config.s3.sessionToken = process.env.EXPORT_S3_SESSION_TOKEN;
config.s3.region = process.env.EXPORT_S3_REGION || 'eu-central-1'; // Default: Europe (Frankfurt)
config.s3.bucketNameDefault = process.env.EXPORT_S3_BUCKET_NAME || 'export';
config.job = {
// Interval takes priority over schedule and must be greater than 0 to be valid
purgeCache: {
interval: Number(process.env.JOB_INTERVAL_CACHE_PURGE) || 0,
schedule: process.env.JOB_SCHEDULE_CACHE_PURGE || '45 4 * * *',
},
};
module.exports = config;