diff --git a/package-lock.json b/package-lock.json index 187e5a1..8db7893 100644 --- a/package-lock.json +++ b/package-lock.json @@ -936,6 +936,21 @@ "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" }, + "lodash.omit": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz", + "integrity": "sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA=" + }, + "lodash.omitby": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.omitby/-/lodash.omitby-4.6.0.tgz", + "integrity": "sha1-XBX/R1StVVAWtTwEExHo8HkgR5E=" + }, + "lodash.partial": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/lodash.partial/-/lodash.partial-4.2.1.tgz", + "integrity": "sha1-SfPYz9qjv/izqR0SfpIyRUGJYdQ=" + }, "lolex": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.4.tgz", @@ -1622,11 +1637,6 @@ "dev": true, "optional": true }, - "underscore": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", - "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" - }, "unicode-5.2.0": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/unicode-5.2.0/-/unicode-5.2.0-0.7.5.tgz", diff --git a/package.json b/package.json index 219d28a..fc9cfaa 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,15 @@ "expect.js": "^0.3.1", "express": "^4.16.3", "json3": "^3.3.2", + "lodash.omit": "^4.5.0", + "lodash.omitby": "^4.6.0", + "lodash.partial": "^4.2.1", "mocha": "^5.2.0", "morgan": "^1.9.0", "q": "^1.5.1", "request": "^2.88.0", "serverless-http": "^1.6.0", - "sinon": "^4.5.0", - "underscore": "^1.9.1" + "sinon": "^4.5.0" }, "devDependencies": { "blanket": "^1.1.7", diff --git a/server/cloudflare.js b/server/cloudflare.js index 0fe72cc..831c59b 100644 --- a/server/cloudflare.js +++ b/server/cloudflare.js @@ -1,10 +1,10 @@ 'use strict'; -const u = require('underscore'); +const omitBy = require('lodash.omitby'); // remove all CloudFlare headers, since they block requests that are already proxied (through the jsonp.afeld.me) module.exports.filterHeaders = function(headers) { - return u.omit(headers, function(val, header) { + return omitBy(headers, function(val, header) { return /^cf-/.test(header); }); }; diff --git a/server/proxy-request.js b/server/proxy-request.js index 81510b6..a1a7553 100644 --- a/server/proxy-request.js +++ b/server/proxy-request.js @@ -1,12 +1,12 @@ 'use strict'; const requestp = require('./requestp'); -const u = require('underscore'); +const omit = require('lodash.omit'); const cloudflare = require('./cloudflare'); let passThroughHeaders = function(incomingHeaders) { // remove those that node should generate - let externalReqHeaders = u.omit( + let externalReqHeaders = omit( incomingHeaders, 'accept-encoding', 'connection', diff --git a/server/router.js b/server/router.js index a7821f6..fd7cb40 100644 --- a/server/router.js +++ b/server/router.js @@ -1,7 +1,8 @@ 'use strict'; const express = require('express'); -const u = require('underscore'); +const omit = require('lodash.omit'); +const partial = require('lodash.partial'); const JSON3 = require('json3'); const snippets = require('./snippets'); const proxy = require('./proxy-request'); @@ -22,7 +23,7 @@ let serveLandingPage = function(req, res) { let passBackHeaders = function(incomingHeaders) { // remove those that node should generate - let resultHeaders = u.omit( + let resultHeaders = omit( incomingHeaders, 'connection', 'content-length', @@ -71,7 +72,7 @@ let doProxy = function(apiUrl, req, res) { // keep this right before respond() to handle errors from any previous steps errorToJson ) - .then(u.partial(respond, res)) + .then(partial(respond, res)) .done(); };