Skip to content

Commit 03e948e

Browse files
committed
Verification report
1 parent 05e81c8 commit 03e948e

File tree

5 files changed

+234
-10
lines changed

5 files changed

+234
-10
lines changed

package-lock.json

Lines changed: 177 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"formidable": "^1.2.1",
3131
"fs-extra": "^2.0.0",
3232
"gonode": "^0.1.2",
33+
"html-pdf": "^2.2.0",
3334
"json-stringify-pretty-compact": "^1.2.0",
3435
"jsonwebtoken": "^7.3.0",
3536
"log4js": "^0.6.38",

server.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ var sjcl = require('sjcl');
1414
var stringify = require("json-stringify-pretty-compact");
1515
var waitUntil = require('wait-until');
1616
var nodemailer = require('nodemailer');
17+
var pdf = require('html-pdf');
18+
1719
const execSync = require('child_process').execSync;
1820
const syncClient = require('sync-rest-client');
1921

@@ -136,6 +138,7 @@ app.use("/sjcl.js", express.static(__dirname + "/lib/sjcl.js"));
136138
app.use("/swal-forms.js", express.static(__dirname + "/lib/swal-forms.js"));
137139
app.use("/swal-forms.css", express.static(__dirname + "/lib/swal-forms.css"));
138140
app.use("/images", express.static(__dirname + "/images"));
141+
app.use("/report", express.static(__dirname + "/report"));
139142

140143
app.get('/', function(req, res){
141144
response_client_html(res, "templatemo_485_rainbow/index.html");
@@ -452,6 +455,23 @@ app.post('/query-by-chaincodes', function(req, res) {
452455

453456
});
454457

458+
app.post('/create-verification-report', function(req, res) {
459+
logger.info("create-verification-report");
460+
461+
var outputhtml = req.body.outputhtml;
462+
var reportID = req.body.reportID;
463+
var options = { format: 'Letter' };
464+
var pdfPath = "/report/" + "veri-report" + (new Date().toString()) + ".pdf";
465+
var pdfPathFull = __dirname + pdfPath;
466+
467+
pdf.create(outputhtml, options).toFile(pdfPathFull, function(err, pdfRes) {
468+
if (err) return console.log(err);
469+
logger.info(pdfPath);
470+
res.write(pdfPath);
471+
res.end();
472+
});
473+
});
474+
455475
app.post('/query-by-block-by-number', function(req, res) {
456476

457477
});

0 commit comments

Comments
 (0)