Check config on load (#4170)
Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
This commit is contained in:
		| @@ -42,9 +42,10 @@ const index = { | ||||
| }; | ||||
|  | ||||
| // Init ElasticSearch connection | ||||
| const client = config.elasticsearch ? new elasticsearch.Client({ | ||||
| 	host: `${config.elasticsearch.host}:${config.elasticsearch.port}` | ||||
| }) : null; | ||||
|  | ||||
| const client = config.elasticsearch.map(({ host, port }) => { | ||||
| 	return new elasticsearch.Client({ host: `${host}:${port}` }); | ||||
| }).getOrElse(null); | ||||
|  | ||||
| if (client) { | ||||
| 	// Send a HEAD request | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import config from '../config'; | ||||
|  | ||||
| const u = config.mongodb.user ? encodeURIComponent(config.mongodb.user) : null; | ||||
| const p = config.mongodb.pass ? encodeURIComponent(config.mongodb.pass) : null; | ||||
| const u = config.mongodb.user.map(x => encodeURIComponent(x)).getOrElse(null); | ||||
| const p = config.mongodb.pass.map(x => encodeURIComponent(x)).getOrElse(null); | ||||
|  | ||||
| const uri = `mongodb://${u && p ? `${u}:${p}@` : ''}${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`; | ||||
|  | ||||
|   | ||||
| @@ -1,10 +1,8 @@ | ||||
| import * as redis from 'redis'; | ||||
| import config from '../config'; | ||||
|  | ||||
| export default config.redis ? redis.createClient( | ||||
| 	config.redis.port, | ||||
| 	config.redis.host, | ||||
| 	{ | ||||
| 		auth_pass: config.redis.pass | ||||
| 	} | ||||
| ) : null; | ||||
| export default config.redis.map(({ host, port, pass }) => { | ||||
| 	return redis.createClient(port, host, { | ||||
| 		auth_pass: pass.getOrElse(null) | ||||
| 	}); | ||||
| }).getOrElse(null); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Aya Morisawa
					Aya Morisawa