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

Commit

Permalink
Using path.join
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo268la committed Apr 29, 2022
1 parent 9767ed2 commit 27a91d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const PDFGenerator = require("pdfkit");
const fs = require("fs");
const path = require("path");

class InvoiceGenerator {
invoice: any;
Expand Down Expand Up @@ -189,7 +190,9 @@ class InvoiceGenerator {
const fileName = this.invoice.invoiceNumber + ".pdf";

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

this.generateHeaders(theOutput);

Expand Down
2 changes: 1 addition & 1 deletion restapi/utils/PDFHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PDFGenerator = require("pdfkit");

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

const orderFound = await orderModel.findOne({
code: code,
Expand Down

0 comments on commit 27a91d9

Please sign in to comment.