From 5448c22031d66cc020323bf4c4d1701889a46485 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 7 Feb 2019 21:02:33 +0900 Subject: Revert 96bc17aa1014983d5e6bf8b4c05d898156995a0d --- src/db/elasticsearch.ts | 7 +++---- src/db/mongodb.ts | 4 ++-- src/db/redis.ts | 12 +++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src/db') diff --git a/src/db/elasticsearch.ts b/src/db/elasticsearch.ts index 68ad736b25..cbe6afbbb9 100644 --- a/src/db/elasticsearch.ts +++ b/src/db/elasticsearch.ts @@ -42,10 +42,9 @@ const index = { }; // Init ElasticSearch connection - -const client = config.elasticsearch.map(({ host, port }) => { - return new elasticsearch.Client({ host: `${host}:${port}` }); -}).getOrElse(null); +const client = config.elasticsearch ? new elasticsearch.Client({ + host: `${config.elasticsearch.host}:${config.elasticsearch.port}` +}) : null; if (client) { // Send a HEAD request diff --git a/src/db/mongodb.ts b/src/db/mongodb.ts index 3e7d40fde7..dedb289ce9 100644 --- a/src/db/mongodb.ts +++ b/src/db/mongodb.ts @@ -1,7 +1,7 @@ import config from '../config'; -const u = config.mongodb.user.map(x => encodeURIComponent(x)).getOrElse(null); -const p = config.mongodb.pass.map(x => encodeURIComponent(x)).getOrElse(null); +const u = config.mongodb.user ? encodeURIComponent(config.mongodb.user) : null; +const p = config.mongodb.pass ? encodeURIComponent(config.mongodb.pass) : null; const uri = `mongodb://${u && p ? `${u}:${p}@` : ''}${config.mongodb.host}:${config.mongodb.port}/${config.mongodb.db}`; diff --git a/src/db/redis.ts b/src/db/redis.ts index 4193ac7e7b..48e3f4e43e 100644 --- a/src/db/redis.ts +++ b/src/db/redis.ts @@ -1,8 +1,10 @@ import * as redis from 'redis'; import config from '../config'; -export default config.redis.map(({ host, port, pass }) => { - return redis.createClient(port, host, { - auth_pass: pass.getOrElse(null) - }); -}).getOrElse(null); +export default config.redis ? redis.createClient( + config.redis.port, + config.redis.host, + { + auth_pass: config.redis.pass + } +) : null; -- cgit v1.2.3-freya