-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 1.35 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
import SolrProxy from 'solr-proxy';
const optionsEnv = {
listenPort: 'PORT',
validHttpMethods: 'VALID_HTTP_METHODS',
validPaths: 'VALID_PATHS',
invalidParams: 'INVALID_PARAMS',
backend: {
host: 'SOLR_HOST',
port: 'SOLR_PORT',
},
maxRows: 'MAX_ROWS',
maxStart: 'MAX_START',
}
const options = {
listenHost: '0.0.0.0',
listenPort: parseInt(process.env[optionsEnv.listenPort], 10) || 8008,
validHttpMethods: process.env[optionsEnv.validHttpMethods] ? process.env[optionsEnv.validHttpMethods].split(',') : ['GET'],
validPaths: process.env[optionsEnv.validPaths] ? process.env[optionsEnv.validPaths].split(',') : ['/solr/select'],
invalidParams: process.env[optionsEnv.invalidParams] ? process.env[optionsEnv.invalidParams].split(',') : ['qt', 'stream'],
upstream: 'http://' + (process.env[optionsEnv.backend.host] || 'solr') + ':' + (parseInt(process.env[optionsEnv.backend.port], 10) || 8983),
maxRows: parseInt(process.env[optionsEnv.maxRows], 10) || 200,
maxStart: parseInt(process.env[optionsEnv.maxStart], 10) || 1000
}
console.log(`Starting Server on Port ${options.listenPort}`);
console.log(`Connection setup to ${options.upstream}`);
console.log(`Options can be set via Following ENV variables:`);
console.log(optionsEnv);
console.log(`Options used for solr-proxy:`);
console.log(options);
SolrProxy.start(options.listenPort, options);