diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..5e08342 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +**/*.min.js +config.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..201496c --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "env": { + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 2 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ] + } +} diff --git a/README.md b/README.md index 5dee91c..96db569 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ or post. All of which are optional except `type` with very logical default values. +If your Redis server is configured for password authentification, use the `password` field. + ### Postgres To use postgres storage you must install the `pg` package in npm diff --git a/about.md b/about.md index 69103d5..53cc39a 100644 --- a/about.md +++ b/about.md @@ -15,7 +15,7 @@ To make a new entry, click "New" (or type 'control + n') ## From the Console -Most of the time I want to show you some text, its coming from my current +Most of the time I want to show you some text, it's coming from my current console session. We should make it really easy to take code from the console and send it to people. diff --git a/lib/document_stores/memcached.js b/lib/document_stores/memcached.js index 5aac673..2771886 100644 --- a/lib/document_stores/memcached.js +++ b/lib/document_stores/memcached.js @@ -26,7 +26,7 @@ MemcachedDocumentStore.connect = function(options) { // Save file in a key MemcachedDocumentStore.prototype.set = function(key, data, callback, skipExpire) { - MemcachedDocumentStore.client.set(key, data, function(err, reply) { + MemcachedDocumentStore.client.set(key, data, function(err) { err ? callback(false) : callback(true); }, skipExpire ? 0 : this.expire); }; diff --git a/lib/document_stores/postgres.js b/lib/document_stores/postgres.js index c712e1f..dbb471c 100644 --- a/lib/document_stores/postgres.js +++ b/lib/document_stores/postgres.js @@ -23,7 +23,7 @@ PostgresDocumentStore.prototype = { key, data, that.expireJS && !skipExpire ? that.expireJS + now : null - ], function (err, result) { + ], function (err) { if (err) { winston.error('error persisting value to postgres', { error: err }); return callback(false); @@ -50,7 +50,7 @@ PostgresDocumentStore.prototype = { client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [ that.expireJS + now, result.rows[0].id - ], function (err, result) { + ], function (err) { if (!err) { done(); } diff --git a/lib/document_stores/redis.js b/lib/document_stores/redis.js index 3f72d4b..7edbaf0 100644 --- a/lib/document_stores/redis.js +++ b/lib/document_stores/redis.js @@ -29,7 +29,7 @@ RedisDocumentStore.connect = function(options) { if (options.password) { RedisDocumentStore.client.auth(options.password); } - RedisDocumentStore.client.select(index, function(err, reply) { + RedisDocumentStore.client.select(index, function(err) { if (err) { winston.error( 'error connecting to redis index ' + index, @@ -46,7 +46,7 @@ RedisDocumentStore.connect = function(options) { // Save file in a key RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) { var _this = this; - RedisDocumentStore.client.set(key, data, function(err, reply) { + RedisDocumentStore.client.set(key, data, function(err) { if (err) { callback(false); } @@ -62,7 +62,7 @@ RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) { // Expire a key in expire time if set RedisDocumentStore.prototype.setExpiration = function(key) { if (this.expire) { - RedisDocumentStore.client.expire(key, this.expire, function(err, reply) { + RedisDocumentStore.client.expire(key, this.expire, function(err) { if (err) { winston.error('failed to set expiry on key: ' + key); } diff --git a/lib/key_generators/dictionary.js b/lib/key_generators/dictionary.js new file mode 100644 index 0000000..900ac29 --- /dev/null +++ b/lib/key_generators/dictionary.js @@ -0,0 +1,24 @@ +var fs = require('fs'); + +var DictionaryGenerator = function(options) { + //Options + 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; + this.dictionary = data.split(/[\n\r]+/); + }); +}; + +//Generates a dictionary-based key, of keyLength words +DictionaryGenerator.prototype.createKey = function(keyLength) { + var text = ''; + for(var i = 0; i < keyLength; i++) + text += this.dictionary[Math.floor(Math.random() * this.dictionary.length)]; + + return text; +}; + +module.exports = DictionaryGenerator; diff --git a/lib/key_generators/phonetic.js b/lib/key_generators/phonetic.js index 011900b..cb13a19 100644 --- a/lib/key_generators/phonetic.js +++ b/lib/key_generators/phonetic.js @@ -1,5 +1,5 @@ // Draws inspiration from pwgen and http://tools.arantius.com/password -var PhoneticKeyGenerator = function(options) { +var PhoneticKeyGenerator = function() { // No options }; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8fd3e34 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,511 @@ +{ + "name": "haste", + "version": "0.1.0", + "lockfileVersion": 1, + "dependencies": { + "async": { + "version": "0.1.22", + "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", + "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=" + }, + "async-cache": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-cache/-/async-cache-1.0.0.tgz", + "integrity": "sha1-yH9tgMcrOU7g+QYe3rJNjEtiKto=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.0.3.tgz", + "integrity": "sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4=", + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=" + } + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "buffer-writer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.0.tgz", + "integrity": "sha1-bCnDst6gyeRVofJhoZmkigT4iwg=" + }, + "busboy": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.4.tgz", + "integrity": "sha1-GXfpbh7ohGSWUevfVIypAHWLp/M=" + }, + "colors": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", + "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=" + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "connect": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.4.1.tgz", + "integrity": "sha1-ohNh0/QJnvdhzabcSpc7seuwo00=" + }, + "connect-ratelimit": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/connect-ratelimit/-/connect-ratelimit-0.0.7.tgz", + "integrity": "sha1-5uCclQZJ6ElJnKsYcKQVoH9zFWg=" + }, + "connect-route": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/connect-route/-/connect-route-0.1.5.tgz", + "integrity": "sha1-48IYMZ0uiKiprgsOD+Cacpw5dEo=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "cycle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", + "integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI=" + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=" + }, + "dicer": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.3.tgz", + "integrity": "sha1-8AKBGJpVwjUe+ASQpP6fssWcSTk=" + }, + "diff": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", + "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", + "dev": true + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=" + }, + "fd": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/fd/-/fd-0.0.2.tgz", + "integrity": "sha1-4O2yvXqIzIbdnxY5HLqDJBj9h+4=" + }, + "finalhandler": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.4.1.tgz", + "integrity": "sha1-haF8bFmpRxfSYtYSMNSw6+PUoU0=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "generic-pool": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-2.1.1.tgz", + "integrity": "sha1-rwTcLDJc/Ll1Aj+lK/zpYXp0Nf0=" + }, + "glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "optional": true + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "dev": true + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "json3": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", + "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", + "dev": true + }, + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "dev": true + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basecreate": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", + "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash.create": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", + "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", + "dev": true + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true + }, + "lru-cache": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.3.1.tgz", + "integrity": "sha1-s632s9hW6VTiw5DmzvIggSRaU9Y=" + }, + "mime": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.6.tgz", + "integrity": "sha1-WR2E02U6awtKO5343lqoEI5y5eA=" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true + }, + "mocha": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.4.2.tgz", + "integrity": "sha1-0O9NMyEm2/GNDWQMmzgt1IvpdZQ=", + "dev": true, + "dependencies": { + "debug": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz", + "integrity": "sha1-vFlryr52F/Edn6FTYe3tVgi4SZs=", + "dev": true + }, + "ms": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "dev": true + } + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true + }, + "packet-reader": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-0.2.0.tgz", + "integrity": "sha1-gZ300BC4LV6lZx+KGjrPA5vNdwA=" + }, + "parseurl": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "pg": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/pg/-/pg-4.1.1.tgz", + "integrity": "sha1-mEgKz8089qP5Yhyl1FiUFVgqVzI=" + }, + "pg-connection-string": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz", + "integrity": "sha1-2hhHsglA5C7hSSvq9l1J2RskXfc=" + }, + "pg-types": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.6.0.tgz", + "integrity": "sha1-OHKg8ZkUMCVJf07ipl/a8A1+qLM=" + }, + "pgpass": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-0.0.3.tgz", + "integrity": "sha1-EuZ+NDsxicLzEgbrycwL7//PkUA=" + }, + "pkginfo": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.2.3.tgz", + "integrity": "sha1-cjnEKl72wwuPMoQ52bn/cQQkkPg=" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=" + }, + "redis": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/redis/-/redis-0.8.1.tgz", + "integrity": "sha1-FZ8hMFmaL3GeRLA/C0t2EvmS/LI=" + }, + "redis-url": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/redis-url/-/redis-url-0.1.0.tgz", + "integrity": "sha1-TaXlsYG2wMrW4aVcf1Co5u53ebs=" + }, + "request": { + "version": "2.9.203", + "resolved": "https://registry.npmjs.org/request/-/request-2.9.203.tgz", + "integrity": "sha1-bBcRpUB/uUoRQhlWPkQUW8v0cjo=" + }, + "semver": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=" + }, + "should": { + "version": "11.2.1", + "resolved": "https://registry.npmjs.org/should/-/should-11.2.1.tgz", + "integrity": "sha1-kPVRRVUtAc/CAGZuToGKHJZw7aI=", + "dev": true + }, + "should-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-1.0.1.tgz", + "integrity": "sha1-C26VFvJgGp+wuy3MNpr6HH4gCvc=", + "dev": true + }, + "should-format": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", + "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", + "dev": true + }, + "should-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", + "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", + "dev": true + }, + "should-type-adaptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.0.1.tgz", + "integrity": "sha1-7+VVPN9oz/ZuXF9RtxLcNRx3vqo=", + "dev": true + }, + "should-util": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", + "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=", + "dev": true + }, + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=" + }, + "st": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/st/-/st-1.1.0.tgz", + "integrity": "sha1-c7ltsLdkTZp4zjg0o+T37G6Hz3Y=" + }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" + }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "supports-color": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "uglify-js": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-1.3.3.tgz", + "integrity": "sha1-3dPpiqJ/X0flic+z+VzduiYJYZA=" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "utils-merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=" + }, + "winston": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/winston/-/winston-0.6.2.tgz", + "integrity": "sha1-QUT+JYbNwZphK/jANVkBMskGS9I=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} diff --git a/server.js b/server.js index d304643..0a54f1e 100644 --- a/server.js +++ b/server.js @@ -1,5 +1,4 @@ var http = require('http'); -var url = require('url'); var fs = require('fs'); var winston = require('winston'); @@ -19,7 +18,10 @@ config.host = process.env.HOST || config.host || 'localhost'; if (config.logging) { try { winston.remove(winston.transports.Console); - } catch(er) { } + } catch(e) { + /* was not present */ + } + var detail, type; for (var i = 0; i < config.logging.length; i++) { detail = config.logging[i]; @@ -52,16 +54,14 @@ else { // Compress the static javascript assets if (config.recompressStaticAssets) { - var jsp = require("uglify-js").parser; - var pro = require("uglify-js").uglify; + var jsp = require('uglify-js').parser; + var pro = require('uglify-js').uglify; var list = fs.readdirSync('./static'); - for (var i = 0; i < list.length; i++) { + for (var j = 0; j < list.length; j++) { var item = list[i]; var orig_code, ast; - if ((item.indexOf('.js') === item.length - 3) && - (item.indexOf('.min.js') === -1)) { - dest = item.substring(0, item.length - 3) + '.min' + - item.substring(item.length - 3); + if ((item.indexOf('.js') === item.length - 3) && (item.indexOf('.min.js') === -1)) { + var dest = item.substring(0, item.length - 3) + '.min' + item.substring(item.length - 3); orig_code = fs.readFileSync('./static/' + item, 'utf8'); ast = jsp.parse(orig_code); ast = pro.ast_mangle(ast); @@ -113,17 +113,17 @@ if (config.rateLimits) { // first look at API calls app.use(route(function(router) { // get raw documents - support getting with extension - router.get('/raw/:id', function(request, response, next) { + router.get('/raw/:id', function(request, response) { var key = request.params.id.split('.')[0]; var skipExpire = !!config.documents[key]; return documentHandler.handleRawGet(key, response, skipExpire); }); // add documents - router.post('/documents', function(request, response, next) { + router.post('/documents', function(request, response) { return documentHandler.handlePost(request, response); }); // get documents - router.get('/documents/:id', function(request, response, next) { + router.get('/documents/:id', function(request, response) { var key = request.params.id.split('.')[0]; var skipExpire = !!config.documents[key]; return documentHandler.handleGet(key, response, skipExpire); diff --git a/spec/document_handler_spec.js b/spec/document_handler_spec.js index e31eae8..d646a4e 100644 --- a/spec/document_handler_spec.js +++ b/spec/document_handler_spec.js @@ -1,3 +1,5 @@ +/* global describe, it */ + var DocumentHandler = require('../lib/document_handler'); var Generator = require('../lib/key_generators/random'); diff --git a/spec/redis_document_store_spec.js b/spec/redis_document_store_spec.js index 8e2faf7..5ad2e56 100644 --- a/spec/redis_document_store_spec.js +++ b/spec/redis_document_store_spec.js @@ -1,3 +1,5 @@ +/* global it, describe, afterEach */ + var RedisDocumentStore = require('../lib/document_stores/redis'); var winston = require('winston'); @@ -12,7 +14,7 @@ describe('redis_document_store', function() { RedisDocumentStore.client = false; } }); - + describe('set', function() { it('should be able to set a key and have an expiration set', function(done) { @@ -37,7 +39,7 @@ describe('redis_document_store', function() { it('should not set an expiration when expiration is off', function(done) { var store = new RedisDocumentStore({ expire: false }); - store.set('hello3', 'world', function(worked) { + store.set('hello3', 'world', function() { RedisDocumentStore.client.ttl('hello3', function(err, res) { res.should.equal(-1); done(); diff --git a/static/application.js b/static/application.js index f2a8023..d936cd9 100644 --- a/static/application.js +++ b/static/application.js @@ -1,3 +1,5 @@ +/* global $, hljs, window, document */ + ///// represents a single document var haste_document = function() { @@ -42,10 +44,10 @@ haste_document.prototype.load = function(key, callback, lang) { value: high.value, key: key, language: high.language || lang, - lineCount: res.data.split("\n").length + lineCount: res.data.split('\n').length }); }, - error: function(err) { + error: function() { callback(false); } }); @@ -71,7 +73,7 @@ haste_document.prototype.save = function(data, callback) { value: high.value, key: res.key, language: high.language, - lineCount: data.split("\n").length + lineCount: data.split('\n').length }); }, error: function(res) { @@ -276,7 +278,7 @@ haste.prototype.configureButtons = function() { $where: $('#box2 .new'), label: 'New', shortcut: function(evt) { - return evt.ctrlKey && evt.keyCode === 78 + return evt.ctrlKey && evt.keyCode === 78; }, shortcutDescription: 'control + n', action: function() { @@ -331,14 +333,14 @@ haste.prototype.configureButton = function(options) { } }); // Show the label - options.$where.mouseenter(function(evt) { + options.$where.mouseenter(function() { $('#box3 .label').text(options.label); $('#box3 .shortcut').text(options.shortcutDescription || ''); $('#box3').show(); $(this).append($('#pointer').remove().show()); }); // Hide the label - options.$where.mouseleave(function(evt) { + options.$where.mouseleave(function() { $('#box3').hide(); $('#pointer').hide(); }); @@ -371,7 +373,7 @@ $(function() { // For browsers like Internet Explorer if (document.selection) { this.focus(); - sel = document.selection.createRange(); + var sel = document.selection.createRange(); sel.text = myValue; this.focus(); } diff --git a/static/application.min.js b/static/application.min.js index 0fd07b2..0a2a91d 100644 --- a/static/application.min.js +++ b/static/application.min.js @@ -1 +1 @@ -var haste_document=function(){this.locked=!1};haste_document.prototype.htmlEscape=function(e){return e.replace(/&/g,"&").replace(/>/g,">").replace(/'+e+"");$("#messages").prepend(n),setTimeout(function(){n.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","twitter","raw"])},haste.prototype.configureKey=function(e){var t,n=0;$("#box2 .function").each(function(){t=$(this);for(n=0;n";$("#linenos").html(t)},haste.prototype.removeLineNumbers=function(){$("#linenos").html(">")},haste.prototype.loadDocument=function(e){var t=e.split(".",2),n=this;n.doc=new haste_document,n.doc.load(t[0],function(e){e?(n.$code.html(e.value),n.setTitle(e.key),n.fullKey(),n.$textarea.val("").hide(),n.$box.show().focus(),n.addLineNumbers(e.lineCount)):n.newDocument()},this.lookupTypeByExtension(t[1]))},haste.prototype.duplicateDocument=function(){if(this.doc.locked){var e=this.doc.data;this.newDocument(),this.$textarea.val(e)}},haste.prototype.lockDocument=function(){var e=this;this.doc.save(this.$textarea.val(),function(t,n){if(t)e.showMessage(t.message,"error");else if(n){e.$code.html(n.value),e.setTitle(n.key);var r="/"+n.key;n.language&&(r+="."+e.lookupExtensionByType(n.language)),window.history.pushState(null,e.appName+"-"+n.key,r),e.fullKey(),e.$textarea.val("").hide(),e.$box.show().focus(),e.addLineNumbers(n.lineCount)}})},haste.prototype.configureButtons=function(){var e=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcutDescription:"control + s",shortcut:function(e){return e.ctrlKey&&e.keyCode===83},action:function(){e.$textarea.val().replace(/^\s+|\s+$/g,"")!==""&&e.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(e){return e.ctrlKey&&e.keyCode===78},shortcutDescription:"control + n",action:function(){e.newDocument(!e.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(t){return e.doc.locked&&t.ctrlKey&&t.keyCode===68},shortcutDescription:"control + d",action:function(){e.duplicateDocument()}},{$where:$("#box2 .raw"),label:"Just Text",shortcut:function(e){return e.ctrlKey&&e.shiftKey&&e.keyCode===82},shortcutDescription:"control + shift + r",action:function(){window.location.href="/raw/"+e.doc.key}},{$where:$("#box2 .twitter"),label:"Twitter",shortcut:function(t){return e.options.twitter&&e.doc.locked&&t.shiftKey&&t.ctrlKey&&t.keyCode==84},shortcutDescription:"control + shift + t",action:function(){window.open("https://twitter.com/share?url="+encodeURI(window.location.href))}}];for(var t=0;t/g,">").replace(/'+e+"");$("#messages").prepend(n),setTimeout(function(){n.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","twitter","raw"])},haste.prototype.configureKey=function(e){var t,n=0;$("#box2 .function").each(function(){t=$(this);for(n=0;n";$("#linenos").html(t)},haste.prototype.removeLineNumbers=function(){$("#linenos").html(">")},haste.prototype.loadDocument=function(e){var t=e.split(".",2),n=this;n.doc=new haste_document,n.doc.load(t[0],function(e){e?(n.$code.html(e.value),n.setTitle(e.key),n.fullKey(),n.$textarea.val("").hide(),n.$box.show().focus(),n.addLineNumbers(e.lineCount)):n.newDocument()},this.lookupTypeByExtension(t[1]))},haste.prototype.duplicateDocument=function(){if(this.doc.locked){var e=this.doc.data;this.newDocument(),this.$textarea.val(e)}},haste.prototype.lockDocument=function(){var e=this;this.doc.save(this.$textarea.val(),function(t,n){if(t)e.showMessage(t.message,"error");else if(n){e.$code.html(n.value),e.setTitle(n.key);var r="/"+n.key;n.language&&(r+="."+e.lookupExtensionByType(n.language)),window.history.pushState(null,e.appName+"-"+n.key,r),e.fullKey(),e.$textarea.val("").hide(),e.$box.show().focus(),e.addLineNumbers(n.lineCount)}})},haste.prototype.configureButtons=function(){var e=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcutDescription:"control + s",shortcut:function(e){return e.ctrlKey&&e.keyCode===83},action:function(){e.$textarea.val().replace(/^\s+|\s+$/g,"")!==""&&e.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(e){return e.ctrlKey&&e.keyCode===78},shortcutDescription:"control + n",action:function(){e.newDocument(!e.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(t){return e.doc.locked&&t.ctrlKey&&t.keyCode===68},shortcutDescription:"control + d",action:function(){e.duplicateDocument()}},{$where:$("#box2 .raw"),label:"Just Text",shortcut:function(e){return e.ctrlKey&&e.shiftKey&&e.keyCode===82},shortcutDescription:"control + shift + r",action:function(){window.location.href="/raw/"+e.doc.key}},{$where:$("#box2 .twitter"),label:"Twitter",shortcut:function(t){return e.options.twitter&&e.doc.locked&&t.shiftKey&&t.ctrlKey&&t.keyCode==84},shortcutDescription:"control + shift + t",action:function(){window.open("https://twitter.com/share?url="+encodeURI(window.location.href))}}];for(var t=0;t