Skip to content
This repository was archived by the owner on Feb 4, 2024. It is now read-only.

Commit 27a91d9

Browse files
committed
Using path.join
1 parent 9767ed2 commit 27a91d9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

restapi/utils/InvoiceGenerator.ts renamed to restapi/InvoiceGenerator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const PDFGenerator = require("pdfkit");
22
const fs = require("fs");
3+
const path = require("path");
34

45
class InvoiceGenerator {
56
invoice: any;
@@ -189,7 +190,9 @@ class InvoiceGenerator {
189190
const fileName = this.invoice.invoiceNumber + ".pdf";
190191

191192
// pipe to a writable stream which would save the result into the same directory
192-
theOutput.pipe(fs.createWriteStream("./public/pdf/" + fileName));
193+
theOutput.pipe(
194+
fs.createWriteStream(path.join(__dirname, "public", "pdf", fileName))
195+
);
193196

194197
this.generateHeaders(theOutput);
195198

restapi/utils/PDFHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const PDFGenerator = require("pdfkit");
66

77
export const createPDF = async (code: string) => {
88
if (process.env.MONGO_DB_URI === undefined) return;
9-
const InvoiceGenerator = require("./InvoiceGenerator");
9+
const InvoiceGenerator = require("../InvoiceGenerator");
1010

1111
const orderFound = await orderModel.findOne({
1212
code: code,

0 commit comments

Comments
 (0)