From cd3bf26dbe8ed58f87af1b72a56320cbbd8efc36 Mon Sep 17 00:00:00 2001 From: Jacob Gunther <16949253+PassTheMayo@users.noreply.github.com> Date: Mon, 16 Apr 2018 10:52:53 -0500 Subject: [PATCH] Use local method for md5 --- lib/document_stores/rethinkdb.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/document_stores/rethinkdb.js b/lib/document_stores/rethinkdb.js index 04c5b6f..f945fa1 100644 --- a/lib/document_stores/rethinkdb.js +++ b/lib/document_stores/rethinkdb.js @@ -2,6 +2,12 @@ const crypto = require('crypto'); const rethink = require('rethinkdbdash'); const winston = require('winston'); +const md5 = (str) => { + const md5sum = crypto.createHash('md5'); + md5sum.update(str); + return md5sum.digest('hex'); +}; + class RethinkDBStore { constructor(options) { this.client = rethink({ @@ -15,7 +21,7 @@ class RethinkDBStore { } set(key, data, callback) { - this.client.table('uploads').insert({ id: RethinkDBStore.md5(key), data: data }).run((error) => { + this.client.table('uploads').insert({ id: md5(key), data: data }).run((error) => { if (error) { callback(false); winston.error('failed to insert to table', error); @@ -26,7 +32,7 @@ class RethinkDBStore { } get(key, callback) { - this.client.table('uploads').get(RethinkDBStore.md5(key)).run((error, result) => { + this.client.table('uploads').get(md5(key)).run((error, result) => { if (error || !result) { callback(false); winston.error('failed to insert to table', error); @@ -38,8 +44,3 @@ class RethinkDBStore { } module.exports = RethinkDBStore; -module.exports.md5 = (str) => { - const md5sum = crypto.createHash('md5'); - md5sum.update(str); - return md5sum.digest('hex'); -}; \ No newline at end of file