Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
use lodash instead of underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
afeld committed Oct 3, 2018
1 parent 4b1739a commit cbd2297
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
20 changes: 15 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions server/cloudflare.js
Original file line number Diff line number Diff line change
@@ -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);
});
};
4 changes: 2 additions & 2 deletions server/proxy-request.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
7 changes: 4 additions & 3 deletions server/router.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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',
Expand Down Expand Up @@ -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();
};

Expand Down

0 comments on commit cbd2297

Please sign in to comment.