Skip to content

Conversation

@Embotic-Wayne
Copy link
Collaborator

No description provided.

Comment on lines 208 to 216
if(!user){
throw new Error('user not found'); // checks user
}
if(!Number.isInteger(pagesToPrint) || pagesToPrint <= 0){
throw new Error('invalid number');
}
if (user.pagesPrinted < pagesToPrint) {
throw new Error('no pages remaining');
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of throwing an error just do logger.error here and return early, we dont have to return anything

Comment on lines 121 to 126
const stream = await fs.promises.readFile(assembledPdfFromChunks); // buffer
const pdfDoc = await PDFDocument.load(stream); // load PDF
const numpages = pdfDoc.getPages().length; // get number of pages
const copiesInt = parseInt(copies || 1, 10);
const totalPages = numpages * copiesInt;
await subtractUserPages(user.id, totalPages); // updates users printcount
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this code in the existing try block in axios.post(PRINTER_URL ...

Copy link
Collaborator

@efar301 efar301 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants