Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bmblb committed Jan 16, 2025
1 parent 676c1e5 commit 4e1de77
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 32 deletions.
2 changes: 1 addition & 1 deletion __tests__/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function getFile(json, protocol, fileFormat, host, port, timeout) {
});

request.on('timeout', () => {
request.abort();
request.destroy();

reject(new Error('timeout'));
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/samples/fileprotocol/data.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"html": [
{ "html" : "<!DOCTYPE html><html class=\"\" style=\"width: 8.25in; height: 11.69in;\"><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"/><title></title><link rel=\"stylesheet\" href=\"file:///C:/foo.css\"><link rel=\"stylesheet\" href=\"file:///home/bar.css\"><style>body {background-image: url(\"file:///home/buz.css\");}</style><link rel=\"stylesheet\" href=\"https://bryntum.com/examples/build/grid.stockholm.css?455383\"></head><body></body></html>" }
{ "html" : "<!DOCTYPE html><html class=\"\" style=\"width: 8.25in; height: 11.69in;\"><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"/><title></title><link rel=\"stylesheet\" href=\"file:///C:/foo.css\"><link rel=\"stylesheet\" href=\"file:///home/bar.css\"><style>body {background-image: url(\"file:///home/buz.css\");}</style><link rel=\"stylesheet\" href=\"https://bryntum.com/products/grid/build/grid.stockholm.css?455383\"></head><body></body></html>" }
],
"orientation": "portrait",
"format": "A4",
Expand Down
2 changes: 1 addition & 1 deletion __tests__/samples/parallel/parallel2.json

Large diffs are not rendered by default.

Binary file modified __tests__/samples/smoke/base_https.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion __tests__/samples/smoke/base_https.pdf.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion __tests__/samples/smoke/base_https.png.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions __tests__/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ describe('Should export over HTTP', () => {
const
host = 'localhost',
protocol = 'http',
port = 8081,
port = 8082,
workers = 1,
fileFormat = 'pdf';

server = await startServer({ protocol, port, workers, logger : getLoggerConfig('smoke_consequent') });

await assertExportedFile({ protocol, host, port: server.httpPort, fileFormat });

// Waiting for 30 seconds, export server should kill all idle workers
// Waiting for 10 seconds, export server should kill all idle workers
await new Promise(resolve => {
setTimeout(() => resolve(), 30000);
setTimeout(() => resolve(), 10000);
});

const promises = [
assertExportedFile({ protocol, host, port: server.httpPort, fileFormat }),
new Promise(resolve => {
setTimeout(() => {
resolve('timeout');
}, 1000 * 60 * 2);
}, 1000 * 30);
})
];

Expand All @@ -59,7 +59,7 @@ describe('Should export over HTTP', () => {
await Promise.allSettled(promises);

if (winner === 'timeout') {
fail('Server have not returned file in 2 minutes');
fail('Server have not returned file in 30 seconds');
}
});
});
Expand All @@ -69,7 +69,7 @@ describe('Should export over HTTPS', () => {
test('Should export to PDF', async () => {
const
protocol = 'https',
port = 8081,
port = 8083,
workers = 1;

server = await startServer({ protocol, port, workers, logger : getLoggerConfig('smoke_https_pdf') })
Expand Down
88 changes: 79 additions & 9 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"measure": "node ./src/utils/measure-export-time.js"
},
"dependencies": {
"@types/express": "^5.0.0",
"body-parser": "~1.20.3",
"command-line-args": "^6.0.1",
"command-line-usage": "^7.0.3",
Expand Down
2 changes: 0 additions & 2 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ require('winston-daily-rotate-file');

let loggers = {};

let loggerInstance;

module.exports = {
getLogger(config = {}) {
let result;
Expand Down
2 changes: 1 addition & 1 deletion src/server/ExportServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = class ExportServer {
},
dimension = format.split('*');

//format can be send in format 12in*14in. This has precedence over A4, Letter et cetera
// dimensions can be set in format 12in*14in. This has precedence over A4, Letter etc
if (dimension.length === 2) {
config.width = dimension[0];
config.height = dimension[1];
Expand Down
10 changes: 1 addition & 9 deletions src/server/WebServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = class WebServer extends ExportServer {
}

/**
* Create the and initialise the webserver
* Create and initialise the webserver
*
* @param options The passed options from the command line
*/
Expand Down Expand Up @@ -232,14 +232,6 @@ module.exports = class WebServer extends ExportServer {
}
}

getHttpServer() {
return this.httpServer;
}

getHttpsServer() {
return this.httpsServer;
}

/**
* Start the service
*/
Expand Down

0 comments on commit 4e1de77

Please sign in to comment.