Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Old fork was staging #10

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2a2073f
Upgrade puppeteer and ws libraries
eriktrom Mar 2, 2018
4c7f47d
update per assertion error: page.goto param: opts.waitUntil: 'network…
eriktrom Mar 2, 2018
ffd052d
Upgrade puppeteer and ws libraries
eriktrom Mar 2, 2018
1c0d07b
update per assertion error: page.goto param: opts.waitUntil: 'network…
eriktrom Mar 2, 2018
68c8577
bump ws within puppeteer
eriktrom Mar 3, 2018
18ad3d7
remove ws module, puppeteer brings it own
eriktrom Mar 5, 2018
efc109a
use networkIdle0, timeout: 5000
eriktrom Mar 5, 2018
8bbffb8
if url.length > 1024, slice it at 300 chars when logging
eriktrom Mar 5, 2018
e27c2d2
limit pdf to 10mb
eriktrom Mar 5, 2018
8d1174d
suppress long string within error logger
eriktrom Mar 5, 2018
b55e7f0
bump timeout to 2 minutes
eriktrom Mar 5, 2018
29ae5de
better settings try
eriktrom Mar 5, 2018
6408c3c
html: false
eriktrom Mar 5, 2018
2001030
fix please
eriktrom Mar 5, 2018
e1b8216
format: letter; scrollPage: false;
eriktrom Mar 5, 2018
ca2ca25
scroll page automatically
eriktrom Mar 5, 2018
95ca4cc
deepSuppressLongString for req.body
eriktrom Mar 5, 2018
bbec511
Merge remote-tracking branch 'eriktrom/upgrade-puppeteer' into upgrad…
jjculber Mar 5, 2018
56c1986
ALLOW_HTTP=true (override all security hack, for now)
eriktrom Mar 5, 2018
50f706a
ignore non ssl script/css links
eriktrom Mar 5, 2018
3323316
Merge remote-tracking branch 'eriktrom/upgrade-puppeteer' into upgrad…
jjculber Mar 5, 2018
62f7aa7
Merge pull request #3 from RepairShopr/upgrade_puppeteer_with_ws_fix
jjculber Mar 5, 2018
c4455ec
Updated Yarn lockfile
jjculber Mar 5, 2018
361e1c3
Merge branch 'upgrade_puppeteer_with_ws_fix'
jjculber Mar 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: NODE_ENV=production node src/index.js
web: NODE_ENV=production ALLOW_HTTP=true node src/index.js
5,456 changes: 5,456 additions & 0 deletions newman/newman-run-report-2018-03-05-04-28-54-367-0.html

Large diffs are not rendered by default.

5,456 changes: 5,456 additions & 0 deletions newman/newman-run-report-2018-03-05-04-29-24-831-0.html

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
"joi": "^11.1.1",
"lodash": "^4.17.4",
"morgan": "^1.9.0",
"puppeteer": "^0.11.0",
"puppeteer": "https://github.com/repairshopr/puppeteer.git#upgrade-ws-module",
"server-destroy": "^1.0.1",
"winston": "^2.3.1"
"winston": "^2.3.1",
"ws": "^4.1.0"
},
"devDependencies": {
"chai": "^4.1.2",
Expand Down
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function createApp() {
app.use(cors(corsOpts));

// Limit to 10mb if HTML has e.g. inline images
app.use(bodyParser.text({ limit: '4mb', type: 'text/html' }));
app.use(bodyParser.json({ limit: '4mb' }));
app.use(bodyParser.text({ limit: '10mb', type: 'text/html' }));
app.use(bodyParser.json({ limit: '10mb' }));

app.use(compression({
// Compress everything over 10 bytes
Expand Down
16 changes: 10 additions & 6 deletions src/core/pdf-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ const logger = require('../util/logger')(__filename);
async function render(_opts = {}) {
const opts = _.merge({
cookies: [],
scrollPage: false,
scrollPage: true,
emulateScreenMedia: true,
ignoreHttpsErrors: false,
ignoreHttpsErrors: true,
html: null,
viewport: {
width: 1600,
height: 1200,
},
goto: {
waitUntil: 'networkidle',
networkIdleTimeout: 2000,
waitUntil: 'networkidle0',
timeout: 120000,
},
pdf: {
format: 'A4',
format: 'letter',
printBackground: true,
},
}, _opts);
Expand Down Expand Up @@ -130,7 +130,7 @@ async function scrollPage(page) {
setTimeout(scrollDown, scrollInterval);
}

setTimeout(reject, 30000);
setTimeout(reject, 120000);
scrollDown();
});
});
Expand All @@ -142,6 +142,10 @@ function logOpts(opts) {
supressedOpts.html = '...';
}

if (opts.url && opts.url.length > 1024) {
supressedOpts.url = opts.url.slice(0, 300);
}

logger.info(`Rendering with opts: ${JSON.stringify(supressedOpts, null, 2)}`);
}

Expand Down
11 changes: 9 additions & 2 deletions src/middleware/error-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ function getLogLevel(status) {
function logRequestDetails(logLevel, req) {
logger[logLevel]('Request headers:', deepSupressLongStrings(req.headers));
logger[logLevel]('Request parameters:', deepSupressLongStrings(req.params));
logger[logLevel]('Request body:', req.body);
logger[logLevel]('Request body:', deepSupressLongStrings(req.body));
}

function deepSupressLongStrings(obj) {
const newObj = {};
_.each(obj, (val, key) => {
if (_.isString(val) && val.length > SLICE_THRESHOLD) {
newObj[key] = `${val.slice(0, SLICE_THRESHOLD)} ... [CONTENT SLICED]`;
newObj[key] = surpressLongString(val);
} else if (_.isPlainObject(val)) {
deepSupressLongStrings(val);
} else {
Expand All @@ -53,4 +53,11 @@ function deepSupressLongStrings(obj) {
return newObj;
}

function surpressLongString(val) {
if (_.isString(val) && val.length > SLICE_THRESHOLD) {
return `${val.slice(0, SLICE_THRESHOLD)} ... [CONTENT SLICED]`;
}
return val;
}

module.exports = createErrorLogger;
Loading