From e4eeec3d270c7a510097aae76809b8b8d8343387 Mon Sep 17 00:00:00 2001 From: zneix Date: Fri, 28 Aug 2020 04:39:03 +0200 Subject: [PATCH] Updated eslint rules --- .eslintrc.json | 44 +- lib/document_handler.js | 210 +++++----- lib/document_stores/amazon-s3.js | 86 ++-- lib/document_stores/file.js | 82 ++-- lib/document_stores/memcached.js | 72 ++-- lib/document_stores/mongodb.js | 31 +- lib/document_stores/postgres.js | 125 +++--- lib/document_stores/redis.js | 124 +++--- lib/document_stores/rethinkdb.js | 66 +-- lib/key_generators/dictionary.js | 40 +- lib/key_generators/phonetic.js | 24 +- lib/key_generators/random.js | 26 +- lib/util.js | 22 +- package-lock.json | 547 +++++++++++++++++++++++++ package.json | 1 + static/index.html | 4 +- test/document_handler_spec.js | 26 +- test/key_generators/dictionary_spec.js | 42 +- test/redis_document_store_spec.js | 74 ++-- 19 files changed, 1096 insertions(+), 550 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 201496c..53740b5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,25 +1,23 @@ { - "env": { - "es6": true, - "node": true - }, - "extends": "eslint:recommended", - "rules": { - "indent": [ - "error", - 2 - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ] - } + "env": { + "es2020": true, + "node": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 11 + }, + "rules": { + "indent": [ "error", "tab" ], + "linebreak-style": [ "error", "unix" ], + "quotes": [ "error", "single" ], + "semi": [ "error", "always" ], + "no-console": "warn", + "no-unused-vars": "warn", + "max-len": ["warn", 150], + "require-await": "warn" + }, + "globals": { + "winston": "writable" + } } diff --git a/lib/document_handler.js b/lib/document_handler.js index 5f7ca78..44a46de 100644 --- a/lib/document_handler.js +++ b/lib/document_handler.js @@ -3,129 +3,129 @@ const Busboy = require('busboy'); // For handling serving stored documents -const DocumentHandler = function(options) { - if (!options) options = new Object; - this.keyLength = options.keyLength || DocumentHandler.defaultKeyLength; - this.maxLength = options.maxLength; // none by default - this.store = options.store; - this.keyGenerator = options.keyGenerator; +const DocumentHandler = function(options){ + if (!options) options = new Object; + this.keyLength = options.keyLength || DocumentHandler.defaultKeyLength; + this.maxLength = options.maxLength; // none by default + this.store = options.store; + this.keyGenerator = options.keyGenerator; }; DocumentHandler.defaultKeyLength = 10; // Handle retrieving a document -DocumentHandler.prototype.handleGet = async function(key, res, skipExpire) { - await this.store.get(key, function(ret) { - if (ret) { - winston.verbose('retrieved document', { key: key }); - res.writeHead(200, { 'content-type': 'application/json' }); - res.end(JSON.stringify({ data: ret, key: key })); - } - else { - winston.warn('document not found', { key: key }); - res.writeHead(404, { 'content-type': 'application/json' }); - res.end(JSON.stringify({ message: 'Document not found.' })); - } - }, skipExpire); +DocumentHandler.prototype.handleGet = async function(key, res, skipExpire){ + await this.store.get(key, function(ret){ + if (ret){ + winston.verbose('retrieved document', { key: key }); + res.writeHead(200, { 'content-type': 'application/json' }); + res.end(JSON.stringify({ data: ret, key: key })); + } + else { + winston.warn('document not found', { key: key }); + res.writeHead(404, { 'content-type': 'application/json' }); + res.end(JSON.stringify({ message: 'Document not found.' })); + } + }, skipExpire); }; // Handle retrieving the raw version of a document -DocumentHandler.prototype.handleGetRaw = async function(key, res, skipExpire) { - await this.store.get(key, function(ret) { - if (ret) { - winston.verbose('retrieved raw document', { key: key }); - res.writeHead(200, { 'content-type': 'text/plain; charset=UTF-8' }); - res.end(ret); - } - else { - winston.warn('raw document not found', { key: key }); - res.writeHead(404, { 'content-type': 'application/json' }); - res.end(JSON.stringify({ message: 'Document not found.' })); - } - }, skipExpire); +DocumentHandler.prototype.handleGetRaw = async function(key, res, skipExpire){ + await this.store.get(key, function(ret){ + if (ret){ + winston.verbose('retrieved raw document', { key: key }); + res.writeHead(200, { 'content-type': 'text/plain; charset=UTF-8' }); + res.end(ret); + } + else { + winston.warn('raw document not found', { key: key }); + res.writeHead(404, { 'content-type': 'application/json' }); + res.end(JSON.stringify({ message: 'Document not found.' })); + } + }, skipExpire); }; // Handle adding a new Document -DocumentHandler.prototype.handlePost = async function (req, res) { - let _this = this; - let buffer = ''; - let cancelled = false; +DocumentHandler.prototype.handlePost = function (req, res){ + let _this = this; + let buffer = ''; + let cancelled = false; - // What to do when done - let onSuccess = async function () { - // Check length - if (_this.maxLength && buffer.length > _this.maxLength) { - cancelled = true; - winston.warn('document >maxLength', { maxLength: _this.maxLength }); - res.writeHead(400, { 'content-type': 'application/json' }); - res.end( - JSON.stringify({ message: 'Document exceeds maximum length.' }) - ); - return; - } - // And then save if we should - await _this.chooseKey(async function (key) { - await _this.store.set(key, buffer, function (resp) { - if (resp) { - winston.verbose('added document', { key: key }); - res.writeHead(200, { 'content-type': 'application/json' }); - res.end(JSON.stringify({ key: key })); - } - else { - winston.verbose('error adding document'); - res.writeHead(500, { 'content-type': 'application/json' }); - res.end(JSON.stringify({ message: 'Error adding document.' })); - } - }); - }); - }; + // What to do when done + let onSuccess = async function (){ + // Check length + if (_this.maxLength && buffer.length > _this.maxLength){ + cancelled = true; + winston.warn('document >maxLength', { maxLength: _this.maxLength }); + res.writeHead(400, { 'content-type': 'application/json' }); + res.end( + JSON.stringify({ message: 'Document exceeds maximum length.' }) + ); + return; + } + // And then save if we should + await _this.chooseKey(async function (key){ + await _this.store.set(key, buffer, function (resp){ + if (resp){ + winston.verbose('added document', { key: key }); + res.writeHead(200, { 'content-type': 'application/json' }); + res.end(JSON.stringify({ key: key })); + } + else { + winston.verbose('error adding document'); + res.writeHead(500, { 'content-type': 'application/json' }); + res.end(JSON.stringify({ message: 'Error adding document.' })); + } + }); + }); + }; - // If we should, parse a form to grab the data - let ct = req.headers['content-type']; - if (ct && ct.split(';')[0] == 'multipart/form-data') { - let busboy = new Busboy({ headers: req.headers }); - busboy.on('field', function (fieldname, val) { - if (fieldname == 'data') { - buffer = val; - } - }); - busboy.on('finish', async function () { - await onSuccess(); - }); - req.pipe(busboy); - // Otherwise, use our own and just grab flat data from POST body - } else { - req.on('data', function (data) { - buffer += data.toString(); - }); - req.on('end', async function () { - if (cancelled) { return; } - await onSuccess(); - }); - req.on('error', function (error) { - winston.error('connection error: ' + error.message); - res.writeHead(500, { 'content-type': 'application/json' }); - res.end(JSON.stringify({ message: 'Connection error.' })); - cancelled = true; - }); - } + // If we should, parse a form to grab the data + let ct = req.headers['content-type']; + if (ct && ct.split(';')[0] == 'multipart/form-data'){ + let busboy = new Busboy({ headers: req.headers }); + busboy.on('field', function (fieldname, val){ + if (fieldname == 'data'){ + buffer = val; + } + }); + busboy.on('finish', async function (){ + await onSuccess(); + }); + req.pipe(busboy); + // Otherwise, use our own and just grab flat data from POST body + } else { + req.on('data', function (data){ + buffer += data.toString(); + }); + req.on('end', async function (){ + if (cancelled){ return; } + await onSuccess(); + }); + req.on('error', function (error){ + winston.error('connection error: ' + error.message); + res.writeHead(500, { 'content-type': 'application/json' }); + res.end(JSON.stringify({ message: 'Connection error.' })); + cancelled = true; + }); + } }; // Keep choosing keys until one isn't taken -DocumentHandler.prototype.chooseKey = async function(callback) { - let key = this.acceptableKey(); - let _this = this; - await this.store.get(key, function(ret) { - if (ret) { - _this.chooseKey(callback); - } else { - callback(key); - } - }, true); // Don't bump expirations when key searching +DocumentHandler.prototype.chooseKey = async function(callback){ + let key = this.acceptableKey(); + let _this = this; + await this.store.get(key, function(ret){ + if (ret){ + _this.chooseKey(callback); + } else { + callback(key); + } + }, true); // Don't bump expirations when key searching }; -DocumentHandler.prototype.acceptableKey = function() { - return this.keyGenerator.createKey(this.keyLength); +DocumentHandler.prototype.acceptableKey = function(){ + return this.keyGenerator.createKey(this.keyLength); }; module.exports = DocumentHandler; diff --git a/lib/document_stores/amazon-s3.js b/lib/document_stores/amazon-s3.js index 6fd3673..e0b663b 100644 --- a/lib/document_stores/amazon-s3.js +++ b/lib/document_stores/amazon-s3.js @@ -1,56 +1,54 @@ -/*global require,module,process*/ - const AWS = require('aws-sdk'); const winston = require('winston'); -const AmazonS3DocumentStore = function(options) { - this.expire = options.expire; - this.bucket = options.bucket; - this.client = new AWS.S3({region: options.region}); +const AmazonS3DocumentStore = function(options){ + this.expire = options.expire; + this.bucket = options.bucket; + this.client = new AWS.S3({region: options.region}); }; -AmazonS3DocumentStore.prototype.get = function(key, callback, skipExpire) { - const _this = this; +AmazonS3DocumentStore.prototype.get = function(key, callback, skipExpire){ + const _this = this; - const req = { - Bucket: _this.bucket, - Key: key - }; + const req = { + Bucket: _this.bucket, + Key: key + }; - _this.client.getObject(req, function(err, data) { - if(err) { - callback(false); - } - else { - callback(data.Body.toString('utf-8')); - if (_this.expire && !skipExpire) { - winston.warn('amazon s3 store cannot set expirations on keys'); - } - } - }); -} + _this.client.getObject(req, function(err, data){ + if(err){ + callback(false); + } + else { + callback(data.Body.toString('utf-8')); + if (_this.expire && !skipExpire){ + winston.warn('amazon s3 store cannot set expirations on keys'); + } + } + }); +}; -AmazonS3DocumentStore.prototype.set = function(key, data, callback, skipExpire) { - const _this = this; +AmazonS3DocumentStore.prototype.set = function(key, data, callback, skipExpire){ + const _this = this; - const req = { - Bucket: _this.bucket, - Key: key, - Body: data, - ContentType: 'text/plain' - }; + const req = { + Bucket: _this.bucket, + Key: key, + Body: data, + ContentType: 'text/plain' + }; - _this.client.putObject(req, function(err, data) { - if (err) { - callback(false); - } - else { - callback(true); - if (_this.expire && !skipExpire) { - winston.warn('amazon s3 store cannot set expirations on keys'); - } - } - }); -} + _this.client.putObject(req, function(err, data){ + if (err){ + callback(false); + } + else { + callback(true); + if (_this.expire && !skipExpire){ + winston.warn('amazon s3 store cannot set expirations on keys'); + } + } + }); +}; module.exports = AmazonS3DocumentStore; diff --git a/lib/document_stores/file.js b/lib/document_stores/file.js index 8587653..2630422 100644 --- a/lib/document_stores/file.js +++ b/lib/document_stores/file.js @@ -7,57 +7,57 @@ const winston = require('winston'); // options[type] = file // options[path] - Where to store -const FileDocumentStore = function(options) { - this.basePath = options.path || './data'; - this.expire = options.expire; +const FileDocumentStore = function(options){ + this.basePath = options.path || './data'; + this.expire = options.expire; }; // Generate md5 of a string -FileDocumentStore.md5 = function(str) { - let md5sum = crypto.createHash('md5'); - md5sum.update(str); - return md5sum.digest('hex'); +FileDocumentStore.md5 = function(str){ + let md5sum = crypto.createHash('md5'); + md5sum.update(str); + return md5sum.digest('hex'); }; // Save data in a file, key as md5 - since we don't know what we could // be passed here -FileDocumentStore.prototype.set = function(key, data, callback, skipExpire) { - try { - const _this = this; - fs.mkdir(this.basePath, '700', function() { - const fn = _this.basePath + '/' + FileDocumentStore.md5(key); - fs.writeFile(fn, data, 'utf8', function(err) { - if (err) { - callback(false); - } - else { - callback(true); - if (_this.expire && !skipExpire) { - winston.warn('file store cannot set expirations on keys'); - } - } - }); - }); - } catch(err) { - callback(false); - } +FileDocumentStore.prototype.set = function(key, data, callback, skipExpire){ + try { + const _this = this; + fs.mkdir(this.basePath, '700', function(){ + const fn = _this.basePath + '/' + FileDocumentStore.md5(key); + fs.writeFile(fn, data, 'utf8', function(err){ + if (err){ + callback(false); + } + else { + callback(true); + if (_this.expire && !skipExpire){ + winston.warn('file store cannot set expirations on keys'); + } + } + }); + }); + } catch(err){ + callback(false); + } }; // Get data from a file from key -FileDocumentStore.prototype.get = function(key, callback, skipExpire) { - const _this = this; - const fn = require('path').join(this.basePath, FileDocumentStore.md5(key)); - fs.readFile(fn, 'utf8', function(err, data) { - if (err) { - callback(false); - } - else { - callback(data); - if (_this.expire && !skipExpire) { - winston.warn('file store cannot set expirations on keys'); - } - } - }); +FileDocumentStore.prototype.get = function(key, callback, skipExpire){ + const _this = this; + const fn = require('path').join(this.basePath, FileDocumentStore.md5(key)); + fs.readFile(fn, 'utf8', function(err, data){ + if (err){ + callback(false); + } + else { + callback(data); + if (_this.expire && !skipExpire){ + winston.warn('file store cannot set expirations on keys'); + } + } + }); }; module.exports = FileDocumentStore; diff --git a/lib/document_stores/memcached.js b/lib/document_stores/memcached.js index be10db6..221f0b4 100644 --- a/lib/document_stores/memcached.js +++ b/lib/document_stores/memcached.js @@ -3,49 +3,49 @@ const winston = require('winston'); class MemcachedDocumentStore { - // Create a new store with options - constructor(options) { - this.expire = options.expire; + // Create a new store with options + constructor(options){ + this.expire = options.expire; - const host = options.host || '127.0.0.1'; - const port = options.port || 11211; - const url = `${host}:${port}`; - this.connect(url); - } + const host = options.host || '127.0.0.1'; + const port = options.port || 11211; + const url = `${host}:${port}`; + this.connect(url); + } - // Create a connection - connect(url) { - this.client = new memcached(url); + // Create a connection + connect(url){ + this.client = new memcached(url); - winston.info(`connecting to memcached on ${url}`); + winston.info(`connecting to memcached on ${url}`); - this.client.on('failure', function(error) { - winston.info('error connecting to memcached', {error}); - }); - } + this.client.on('failure', function(error){ + winston.info('error connecting to memcached', {error}); + }); + } - // Save file in a key - set(key, data, callback, skipExpire) { - this.client.set(key, data, skipExpire ? 0 : this.expire, (error) => { - callback(!error); - }); - } + // Save file in a key + set(key, data, callback, skipExpire){ + this.client.set(key, data, skipExpire ? 0 : this.expire, (error) => { + callback(!error); + }); + } - // Get a file from a key - get(key, callback, skipExpire) { - this.client.get(key, (error, data) => { - callback(error ? false : data); + // Get a file from a key + get(key, callback, skipExpire){ + this.client.get(key, (error, data) => { + callback(error ? false : data); - // Update the key so that the expiration is pushed forward - if (!skipExpire) { - this.set(key, data, (updateSucceeded) => { - if (!updateSucceeded) { - winston.error('failed to update expiration on GET', {key}); - } - }, skipExpire); - } - }); - } + // Update the key so that the expiration is pushed forward + if (!skipExpire){ + this.set(key, data, (updateSucceeded) => { + if (!updateSucceeded){ + winston.error('failed to update expiration on GET', {key}); + } + }, skipExpire); + } + }); + } } diff --git a/lib/document_stores/mongodb.js b/lib/document_stores/mongodb.js index 71adca2..f42e8fe 100644 --- a/lib/document_stores/mongodb.js +++ b/lib/document_stores/mongodb.js @@ -11,7 +11,7 @@ MongoDocumentStore.prototype.set = async function (key, data, callback, skipExpi const now = Math.floor(Date.now() / 1000); const that = this; - this.safeConnect(async ( {error} = {} ) => { + await this.safeConnect(async ( {error} = {} ) => { if (error) return callback(false); await this.MongoClient.db().collection('entries').updateOne( @@ -32,13 +32,14 @@ MongoDocumentStore.prototype.set = async function (key, data, callback, skipExpi { upsert: true } - ).then((err, result) => { - return callback(true); - }) - .catch((err, result) => { - winston.error('error updating mongodb document', { error: err }); - return callback(false); - }); + ) + .then((err, result) => { + return callback(true); + }) + .catch((err, result) => { + winston.error('error updating mongodb document', { error: err }); + return callback(false); + }); }); }; @@ -47,20 +48,20 @@ MongoDocumentStore.prototype.get = async function (key, callback, skipExpire){ const now = Math.floor(Date.now() / 1000); const that = this; - this.safeConnect(async ( {error} = {} ) => { + await this.safeConnect(async ( {error} = {} ) => { if (error) return callback(false); let document = await this.MongoClient.db().collection('entries').findOne({ 'entry_id': key, - or: [ + $or: [ { expiration: -1 }, { expiration: { $gt: now } } ] }) - .catch(err => { - winston.error('error finding mongodb document', { error: err }); - return callback(false); - }); + .catch(err => { + winston.error('error finding mongodb document', { error: err }); + return callback(false); + }); callback(document ? document.value : false); @@ -71,7 +72,7 @@ MongoDocumentStore.prototype.get = async function (key, callback, skipExpire){ ).catch(err => { return winston.warn('error extending expiry of mongodb document', { error: err }); }); - winston.silly('extended expiry of mongodb document', { key: key, timestamp: that.expire + now }) + winston.silly('extended expiry of mongodb document', { key: key, timestamp: that.expire + now }); } }); }; diff --git a/lib/document_stores/postgres.js b/lib/document_stores/postgres.js index 39c76c7..247b507 100644 --- a/lib/document_stores/postgres.js +++ b/lib/document_stores/postgres.js @@ -1,4 +1,4 @@ -/*global require,module,process*/ +// /*global require,module,process*/ const postgres = require('pg'); const winston = require('winston'); @@ -6,73 +6,74 @@ const winston = require('winston'); // create table entries (id serial primary key, key varchar(255) not null, value text not null, expiration int, unique(key)); // A postgres document store -const PostgresDocumentStore = function (options) { - this.expireJS = options.expire; - this.connectionUrl = process.env.DATABASE_URL || options.connectionUrl; +const PostgresDocumentStore = function (options){ + this.expireJS = options.expire; + this.connectionUrl = process.env.DATABASE_URL || options.connectionUrl; }; PostgresDocumentStore.prototype = { - // Set a given key - set: function (key, data, callback, skipExpire) { - const now = Math.floor(Date.now() / 1000); - const that = this; - this.safeConnect(function (err, client, done) { - if (err) { return callback(false); } - client.query('INSERT INTO entries (key, value, expiration) VALUES ($1, $2, $3)', [ - key, - data, - that.expireJS && !skipExpire ? that.expireJS + now : null - ], function (err) { - if (err) { - winston.error('error persisting value to postgres', { error: err }); - return callback(false); - } - callback(true); - done(); - }); - }); - }, + // Set a given key + set: function (key, data, callback, skipExpire){ + const now = Math.floor(Date.now() / 1000); + const that = this; + this.safeConnect(function (err, client, done){ + if (err){ return callback(false); } + client.query('INSERT INTO entries (key, value, expiration) VALUES ($1, $2, $3)', [ + key, + data, + that.expireJS && !skipExpire ? that.expireJS + now : null + ], function (err){ + if (err){ + winston.error('error persisting value to postgres', { error: err }); + return callback(false); + } + callback(true); + done(); + }); + }); + }, - // Get a given key's data - get: function (key, callback, skipExpire) { - const now = Math.floor(Date.now() / 1000); - const that = this; - this.safeConnect(function (err, client, done) { - if (err) { return callback(false); } - client.query('SELECT id,value,expiration from entries where KEY = $1 and (expiration IS NULL or expiration > $2)', [key, now], function (err, result) { - if (err) { - winston.error('error retrieving value from postgres', { error: err }); - return callback(false); - } - callback(result.rows.length ? result.rows[0].value : false); - if (result.rows.length && that.expireJS && !skipExpire) { - client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [ - that.expireJS + now, - result.rows[0].id - ], function (err) { - if (!err) { - done(); - } - }); - } else { - done(); - } - }); - }); - }, + // Get a given key's data + get: function (key, callback, skipExpire){ + const now = Math.floor(Date.now() / 1000); + const that = this; + this.safeConnect(function (err, client, done){ + if (err){ return callback(false); } + client.query('SELECT id,value,expiration from entries where KEY = $1 and (expiration IS NULL or expiration > $2)', [key, now], + function (err, result){ + if (err){ + winston.error('error retrieving value from postgres', { error: err }); + return callback(false); + } + callback(result.rows.length ? result.rows[0].value : false); + if (result.rows.length && that.expireJS && !skipExpire){ + client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [ + that.expireJS + now, + result.rows[0].id + ], function (err){ + if (!err){ + done(); + } + }); + } else { + done(); + } + }); + }); + }, - // A connection wrapper - safeConnect: function (callback) { - postgres.connect(this.connectionUrl, function (err, client, done) { - if (err) { - winston.error('error connecting to postgres', { error: err }); - callback(err); - } else { - callback(undefined, client, done); - } - }); - } + // A connection wrapper + safeConnect: function (callback){ + postgres.connect(this.connectionUrl, function (err, client, done){ + if (err){ + winston.error('error connecting to postgres', { error: err }); + callback(err); + } else { + callback(undefined, client, done); + } + }); + } }; diff --git a/lib/document_stores/redis.js b/lib/document_stores/redis.js index 0ecb78d..be9618a 100644 --- a/lib/document_stores/redis.js +++ b/lib/document_stores/redis.js @@ -8,82 +8,82 @@ const winston = require('winston'); // options[db] - The db to use (default 0) // options[expire] - The time to live for each key set (default never) -var RedisDocumentStore = function(options, client) { - this.expire = options.expire; - if (client) { - winston.info('using predefined redis client'); - RedisDocumentStore.client = client; - } else if (!RedisDocumentStore.client) { - winston.info('configuring redis'); - RedisDocumentStore.connect(options); - } +var RedisDocumentStore = function(options, client){ + this.expire = options.expire; + if (client){ + winston.info('using predefined redis client'); + RedisDocumentStore.client = client; + } else if (!RedisDocumentStore.client){ + winston.info('configuring redis'); + RedisDocumentStore.connect(options); + } }; // Create a connection according to config -RedisDocumentStore.connect = function(options) { - var host = options.host || '127.0.0.1'; - var port = options.port || 6379; - var index = options.db || 0; - RedisDocumentStore.client = redis.createClient(port, host); - // authenticate if password is provided - if (options.password) { - RedisDocumentStore.client.auth(options.password); - } +RedisDocumentStore.connect = function(options){ + var host = options.host || '127.0.0.1'; + var port = options.port || 6379; + var index = options.db || 0; + RedisDocumentStore.client = redis.createClient(port, host); + // authenticate if password is provided + if (options.password){ + RedisDocumentStore.client.auth(options.password); + } - RedisDocumentStore.client.on('error', function(err) { - winston.error('redis disconnected', err); - }); + RedisDocumentStore.client.on('error', function(err){ + winston.error('redis disconnected', err); + }); - RedisDocumentStore.client.select(index, function(err) { - if (err) { - winston.error( - 'error connecting to redis index ' + index, - { error: err } - ); - process.exit(1); - } - else { - winston.info('connected to redis on ' + host + ':' + port + '/' + index); - } - }); + RedisDocumentStore.client.select(index, function(err){ + if (err){ + winston.error( + 'error connecting to redis index ' + index, + { error: err } + ); + process.exit(1); + } + else { + winston.info('connected to redis on ' + host + ':' + port + '/' + index); + } + }); }; // Save file in a key -RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) { - var _this = this; - RedisDocumentStore.client.set(key, data, function(err) { - if (err) { - callback(false); - } - else { - if (!skipExpire) { - _this.setExpiration(key); - } - callback(true); - } - }); +RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire){ + var _this = this; + RedisDocumentStore.client.set(key, data, function(err){ + if (err){ + callback(false); + } + else { + if (!skipExpire){ + _this.setExpiration(key); + } + callback(true); + } + }); }; // Expire a key in expire time if set -RedisDocumentStore.prototype.setExpiration = function(key) { - if (this.expire) { - RedisDocumentStore.client.expire(key, this.expire, function(err) { - if (err) { - winston.error('failed to set expiry on key: ' + key); - } - }); - } +RedisDocumentStore.prototype.setExpiration = function(key){ + if (this.expire){ + RedisDocumentStore.client.expire(key, this.expire, function(err){ + if (err){ + winston.error('failed to set expiry on key: ' + key); + } + }); + } }; // Get a file from a key -RedisDocumentStore.prototype.get = function(key, callback, skipExpire) { - var _this = this; - RedisDocumentStore.client.get(key, function(err, reply) { - if (!err && !skipExpire) { - _this.setExpiration(key); - } - callback(err ? false : reply); - }); +RedisDocumentStore.prototype.get = function(key, callback, skipExpire){ + var _this = this; + RedisDocumentStore.client.get(key, function(err, reply){ + if (!err && !skipExpire){ + _this.setExpiration(key); + } + callback(err ? false : reply); + }); }; module.exports = RedisDocumentStore; diff --git a/lib/document_stores/rethinkdb.js b/lib/document_stores/rethinkdb.js index ca825af..7489b21 100644 --- a/lib/document_stores/rethinkdb.js +++ b/lib/document_stores/rethinkdb.js @@ -3,44 +3,44 @@ const rethink = require('rethinkdbdash'); const winston = require('winston'); const md5 = (str) => { - const md5sum = crypto.createHash('md5'); - md5sum.update(str); - return md5sum.digest('hex'); + const md5sum = crypto.createHash('md5'); + md5sum.update(str); + return md5sum.digest('hex'); }; class RethinkDBStore { - constructor(options) { - this.client = rethink({ - silent: true, - host: options.host || '127.0.0.1', - port: options.port || 28015, - db: options.db || 'haste', - user: options.user || 'admin', - password: options.password || '' - }); - } + constructor(options){ + this.client = rethink({ + silent: true, + host: options.host || '127.0.0.1', + port: options.port || 28015, + db: options.db || 'haste', + user: options.user || 'admin', + password: options.password || '' + }); + } - set(key, data, callback) { - this.client.table('uploads').insert({ id: md5(key), data: data }).run((error) => { - if (error) { - callback(false); - winston.error('failed to insert to table', error); - return; - } - callback(true); - }); - } + set(key, data, callback){ + this.client.table('uploads').insert({ id: md5(key), data: data }).run((error) => { + if (error){ + callback(false); + winston.error('failed to insert to table', error); + return; + } + callback(true); + }); + } - get(key, callback) { - this.client.table('uploads').get(md5(key)).run((error, result) => { - if (error || !result) { - callback(false); - if (error) winston.error('failed to insert to table', error); - return; - } - callback(result.data); - }); - } + get(key, callback){ + this.client.table('uploads').get(md5(key)).run((error, result) => { + if (error || !result){ + callback(false); + if (error) winston.error('failed to insert to table', error); + return; + } + callback(result.data); + }); + } } module.exports = RethinkDBStore; diff --git a/lib/key_generators/dictionary.js b/lib/key_generators/dictionary.js index 512a14f..93d9b5e 100644 --- a/lib/key_generators/dictionary.js +++ b/lib/key_generators/dictionary.js @@ -2,31 +2,31 @@ const fs = require('fs'); module.exports = class DictionaryGenerator { - constructor(options, readyCallback) { - // Check options format - if (!options) throw Error('No options passed to generator'); - if (!options.path) throw Error('No dictionary path specified in options'); + constructor(options, readyCallback){ + // Check options format + if (!options) throw Error('No options passed to generator'); + if (!options.path) throw Error('No dictionary path specified in options'); - // Load dictionary - fs.readFile(options.path, 'utf8', (err, data) => { - if (err) throw err; + // Load dictionary + fs.readFile(options.path, 'utf8', (err, data) => { + if (err) throw err; - this.dictionary = data.split(/[\n\r]+/); + this.dictionary = data.split(/[\n\r]+/); - if (readyCallback) readyCallback(); - }); - } + if (readyCallback) readyCallback(); + }); + } - // Generates a dictionary-based key, of keyLength words - createKey(keyLength) { - let text = ''; + // Generates a dictionary-based key, of keyLength words + createKey(keyLength){ + let text = ''; - for (let i = 0; i < keyLength; i++) { - const index = Math.floor(Math.random() * this.dictionary.length); - text += this.dictionary[index]; - } + for (let i = 0; i < keyLength; i++){ + const index = Math.floor(Math.random() * this.dictionary.length); + text += this.dictionary[index]; + } - return text; - } + return text; + } }; diff --git a/lib/key_generators/phonetic.js b/lib/key_generators/phonetic.js index 71d1b26..5dd6da2 100644 --- a/lib/key_generators/phonetic.js +++ b/lib/key_generators/phonetic.js @@ -1,9 +1,9 @@ // Draws inspiration from pwgen and http://tools.arantius.com/password const randOf = (collection) => { - return () => { - return collection[Math.floor(Math.random() * collection.length)]; - }; + return () => { + return collection[Math.floor(Math.random() * collection.length)]; + }; }; // Helper methods to get an random vowel or consonant @@ -12,16 +12,16 @@ const randConsonant = randOf('bcdfghjklmnpqrstvwxyz'); module.exports = class PhoneticKeyGenerator { - // Generate a phonetic key of alternating consonant & vowel - createKey(keyLength) { - let text = ''; - const start = Math.floor(Math.random() * 2); + // Generate a phonetic key of alternating consonant & vowel + createKey(keyLength){ + let text = ''; + const start = Math.floor(Math.random() * 2); - for (let i = 0; i < keyLength; i++) { - text += (i % 2 == start) ? randConsonant() : randVowel(); - } + for (let i = 0; i < keyLength; i++){ + text += (i % 2 == start) ? randConsonant() : randVowel(); + } - return text; - } + return text; + } }; diff --git a/lib/key_generators/random.js b/lib/key_generators/random.js index 62f19cb..22677c2 100644 --- a/lib/key_generators/random.js +++ b/lib/key_generators/random.js @@ -1,20 +1,20 @@ module.exports = class RandomKeyGenerator { - // Initialize a new generator with the given keySpace - constructor(options = {}) { - this.keyspace = options.keyspace || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - } + // Initialize a new generator with the given keySpace + constructor(options = {}){ + this.keyspace = options.keyspace || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + } - // Generate a key of the given length - createKey(keyLength) { - let text = ''; + // Generate a key of the given length + createKey(keyLength){ + let text = ''; - for (let i = 0; i < keyLength; i++) { - const index = Math.floor(Math.random() * this.keyspace.length); - text += this.keyspace.charAt(index); - } + for (let i = 0; i < keyLength; i++){ + const index = Math.floor(Math.random() * this.keyspace.length); + text += this.keyspace.charAt(index); + } - return text; - } + return text; + } }; diff --git a/lib/util.js b/lib/util.js index 40c2501..c0e65e5 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,13 +1,13 @@ module.exports = class HasteUtils { - //init class - constructor(options = {}){ - //xd no options for now - } + //init class + constructor(options = {}){ + //xd no options for now + } - //stringify json objects from winston message to cool "key=value" format - stringifyJSONMessagetoLogs(info){ - //really KKona solution, but works for now - let keys = Object.keys(info).filter(k => k != 'message' && k != 'level'); - return keys.map(k => `${k}=${info[k]}`).join(', '); - } -} \ No newline at end of file + //stringify json objects from winston message to cool "key=value" format + stringifyJSONMessagetoLogs(info){ + //really KKona solution, but works for now + let keys = Object.keys(info).filter(k => k != 'message' && k != 'level'); + return keys.map(k => `${k}=${info[k]}`).join(', '); + } +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 082a987..0933696 100644 --- a/package-lock.json +++ b/package-lock.json @@ -306,6 +306,30 @@ "negotiator": "0.6.2" } }, + "acorn": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "dev": true + }, + "acorn-jsx": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", + "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", + "dev": true + }, + "ajv": { + "version": "6.12.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", + "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -364,6 +388,12 @@ "is-string": "^1.0.4" } }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, "async": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", @@ -718,6 +748,12 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -906,6 +942,17 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -920,6 +967,12 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -957,6 +1010,15 @@ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -978,6 +1040,15 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1" + } + }, "es-abstract": { "version": "1.17.6", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", @@ -1046,12 +1117,177 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, + "eslint": { + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.7.0.tgz", + "integrity": "sha512-1KUxLzos0ZVsyL81PnRN335nDtQ8/vZUD6uMtWbF+5zDtjKcsklIi78XoE0MVL93QvWTu+E5y44VyyCsOMBrIg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "enquirer": "^2.3.5", + "eslint-scope": "^5.1.0", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^1.3.0", + "espree": "^7.2.0", + "esquery": "^1.2.0", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash": "^4.17.19", + "minimatch": "^3.0.4", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "progress": "^2.0.0", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + } + } + }, + "eslint-scope": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", + "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + }, + "espree": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz", + "integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==", + "dev": true, + "requires": { + "acorn": "^7.4.0", + "acorn-jsx": "^5.2.0", + "eslint-visitor-keys": "^1.3.0" + } + }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "esquery": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", + "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "dev": true, + "requires": { + "estraverse": "^5.1.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -1111,6 +1347,24 @@ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.1.3.tgz", "integrity": "sha512-TINcxve5510pXj4n9/1AMupkj3iWxl3JuZaWhCdYDlZeoCPqweGZrxbrlqTCFb1CT5wli7s8e2SH/Qz2c9GorA==" }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, "fast-safe-stringify": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", @@ -1126,6 +1380,15 @@ "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.0.tgz", "integrity": "sha512-aN3pcx/DSmtyoovUudctc8+6Hl4T+hI9GBBHLjA76jdZl7+b1sgh5g4k+u/GL3dTy1/pnYzKp69FpJ0OicE3Wg==" }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -1168,6 +1431,23 @@ "is-buffer": "~2.0.3" } }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + } + }, + "flatted": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", + "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "dev": true + }, "fn.name": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", @@ -1206,6 +1486,12 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gensync": { "version": "1.0.0-beta.1", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", @@ -1307,6 +1593,28 @@ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", + "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1482,6 +1790,18 @@ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json5": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", @@ -1495,6 +1815,16 @@ "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==" }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -1656,6 +1986,12 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, "negotiator": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", @@ -1722,6 +2058,20 @@ "fn.name": "1.x.x" } }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, "p-limit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.0.2.tgz", @@ -1751,6 +2101,15 @@ "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -1768,6 +2127,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", @@ -1862,11 +2227,23 @@ "xtend": "^4.0.0" } }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, "promise.allsettled": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz", @@ -1894,6 +2271,12 @@ "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, "qs": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", @@ -1980,6 +2363,12 @@ "redis": ">= 0.0.1" } }, + "regexpp": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", + "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", + "dev": true + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2000,6 +2389,21 @@ "path-parse": "^1.0.6" } }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -2073,6 +2477,21 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, "simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -2081,6 +2500,43 @@ "is-arrayish": "^0.3.1" } }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + } + } + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -2195,11 +2651,57 @@ "has-flag": "^4.0.0" } }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "text-hex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -2229,6 +2731,21 @@ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -2243,6 +2760,15 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -2264,6 +2790,12 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, + "v8-compile-cache": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", + "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", + "dev": true + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -2347,6 +2879,12 @@ } } }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, "workerpool": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.0.tgz", @@ -2422,6 +2960,15 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index 2cc9de8..8a845a5 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "winston": "^3.3.3" }, "devDependencies": { + "eslint": "^7.7.0", "mocha": "^8.1.2" }, "bin": { diff --git a/static/index.html b/static/index.html index 5ed322b..ff41e78 100644 --- a/static/index.html +++ b/static/index.html @@ -18,7 +18,7 @@ // Handle pops let handlePop = function(evt){ let path = evt.target.location.pathname; - if (path == '/') { app.newDocument(true); } + if (path == '/'){ app.newDocument(true); } else { app.loadDocument(path.substring(1, path.length)); } }; // Set up the pop state to handle loads, skipping the first load @@ -26,7 +26,7 @@ // http://code.google.com/p/chromium/issues/detail?id=63040 setTimeout(function(){ window.onpopstate = function(evt){ - try { handlePop(evt); } catch(err) { /* not loaded yet */ } + try { handlePop(evt); } catch(err){ /* not loaded yet */ } }; }, 1000); // Construct app and load initial path diff --git a/test/document_handler_spec.js b/test/document_handler_spec.js index 4f12b49..39b1ff7 100644 --- a/test/document_handler_spec.js +++ b/test/document_handler_spec.js @@ -5,22 +5,22 @@ const assert = require('assert'); const DocumentHandler = require('../lib/document_handler'); const Generator = require('../lib/key_generators/random'); -describe('document_handler', function() { +describe('document_handler', function(){ - describe('randomKey', function() { + describe('randomKey', function(){ - it('should choose a key of the proper length', function() { - let gen = new Generator(); - let dh = new DocumentHandler({ keyLength: 6, keyGenerator: gen }); - assert.equal(6, dh.acceptableKey().length); - }); + it('should choose a key of the proper length', function(){ + let gen = new Generator(); + let dh = new DocumentHandler({ keyLength: 6, keyGenerator: gen }); + assert.equal(6, dh.acceptableKey().length); + }); - it('should choose a default key length', function() { - let gen = new Generator(); - let dh = new DocumentHandler({ keyGenerator: gen }); - assert.equal(dh.keyLength, DocumentHandler.defaultKeyLength); - }); + it('should choose a default key length', function(){ + let gen = new Generator(); + let dh = new DocumentHandler({ keyGenerator: gen }); + assert.equal(dh.keyLength, DocumentHandler.defaultKeyLength); + }); - }); + }); }); diff --git a/test/key_generators/dictionary_spec.js b/test/key_generators/dictionary_spec.js index 72718c7..9abcf26 100644 --- a/test/key_generators/dictionary_spec.js +++ b/test/key_generators/dictionary_spec.js @@ -6,28 +6,28 @@ const fs = require('fs'); const Generator = require('../../lib/key_generators/dictionary'); -describe('RandomKeyGenerator', function() { - describe('randomKey', function() { - it('should throw an error if given no options', () => { - assert.throws(() => { - new Generator(); - }, Error); - }); +describe('RandomKeyGenerator', function(){ + describe('randomKey', function(){ + it('should throw an error if given no options', () => { + assert.throws(() => { + new Generator(); + }, Error); + }); - it('should throw an error if given no path', () => { - assert.throws(() => { - new Generator({}); - }, Error); - }); + it('should throw an error if given no path', () => { + assert.throws(() => { + new Generator({}); + }, Error); + }); - it('should return a key of the proper number of words from the given dictionary', () => { - const path = '/tmp/haste-server-test-dictionary'; - const words = ['cat']; - fs.writeFileSync(path, words.join('\n')); + it('should return a key of the proper number of words from the given dictionary', () => { + const path = '/tmp/haste-server-test-dictionary'; + const words = ['cat']; + fs.writeFileSync(path, words.join('\n')); - const gen = new Generator({path}, () => { - assert.equal('catcatcat', gen.createKey(3)); - }); - }); - }); + const gen = new Generator({path}, () => { + assert.equal('catcatcat', gen.createKey(3)); + }); + }); + }); }); diff --git a/test/redis_document_store_spec.js b/test/redis_document_store_spec.js index d7ba8fc..0708d05 100644 --- a/test/redis_document_store_spec.js +++ b/test/redis_document_store_spec.js @@ -7,48 +7,48 @@ winston.remove(winston.transports.Console); const RedisDocumentStore = require('../lib/document_stores/redis'); -describe('redis_document_store', function() { +describe('redis_document_store', function(){ - /* reconnect to redis on each test */ - afterEach(function() { - if (RedisDocumentStore.client) { - RedisDocumentStore.client.quit(); - RedisDocumentStore.client = false; - } - }); + /* reconnect to redis on each test */ + afterEach(function(){ + if (RedisDocumentStore.client){ + RedisDocumentStore.client.quit(); + RedisDocumentStore.client = false; + } + }); - describe('set', function() { + describe('set', function(){ - it('should be able to set a key and have an expiration set', function(done) { - let store = new RedisDocumentStore({ expire: 10 }); - store.set('hello1', 'world', function() { - RedisDocumentStore.client.ttl('hello1', function(err, res) { - assert.ok(res > 1); - done(); - }); - }); - }); + it('should be able to set a key and have an expiration set', function(done){ + let store = new RedisDocumentStore({ expire: 10 }); + store.set('hello1', 'world', function(){ + RedisDocumentStore.client.ttl('hello1', function(err, res){ + assert.ok(res > 1); + done(); + }); + }); + }); - it('should not set an expiration when told not to', function(done) { - let store = new RedisDocumentStore({ expire: 10 }); - store.set('hello2', 'world', function() { - RedisDocumentStore.client.ttl('hello2', function(err, res) { - assert.equal(-1, res); - done(); - }); - }, true); - }); + it('should not set an expiration when told not to', function(done){ + let store = new RedisDocumentStore({ expire: 10 }); + store.set('hello2', 'world', function(){ + RedisDocumentStore.client.ttl('hello2', function(err, res){ + assert.equal(-1, res); + done(); + }); + }, true); + }); - it('should not set an expiration when expiration is off', function(done) { - let store = new RedisDocumentStore({ expire: false }); - store.set('hello3', 'world', function() { - RedisDocumentStore.client.ttl('hello3', function(err, res) { - assert.equal(-1, res); - done(); - }); - }); - }); + it('should not set an expiration when expiration is off', function(done){ + let store = new RedisDocumentStore({ expire: false }); + store.set('hello3', 'world', function(){ + RedisDocumentStore.client.ttl('hello3', function(err, res){ + assert.equal(-1, res); + done(); + }); + }); + }); - }); + }); });