From 791a5e1268a4c72bc6e393cc04d1e8844606a132 Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Wed, 21 Jan 2026 21:00:21 -0600 Subject: [PATCH] dfgdfg --- server.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/server.js b/server.js index 1cc0782..73e20ae 100644 --- a/server.js +++ b/server.js @@ -316,7 +316,7 @@ app.put('/api/quotes/:id', async (req, res) => { WHERE id = $10 RETURNING *`, [customer_id, quote_date, tax_exempt, tax_rate, - subtotal, tax_amount, total, has_tbd, tbd_note, req.params.id] + subtotal, tax_amount, total, has_tbd, tbd_note, parseInt(req.params.id)] ); console.log('Quote updated, rows affected:', quoteResult.rows.length); @@ -329,7 +329,7 @@ app.put('/api/quotes/:id', async (req, res) => { // Delete old items console.log('Deleting old items'); - await client.query('DELETE FROM quote_items WHERE quote_id = $1', [req.params.id]); + await client.query('DELETE FROM quote_items WHERE quote_id = $1', [parseInt(req.params.id)]); // Insert new items console.log('Inserting', items.length, 'new items'); @@ -338,7 +338,7 @@ app.put('/api/quotes/:id', async (req, res) => { await client.query( `INSERT INTO quote_items (quote_id, quantity, description, rate, amount, is_tbd, item_order) VALUES ($1, $2, $3, $4, $5, $6, $7)`, - [req.params.id, item.quantity, item.description, item.rate, + [parseInt(req.params.id), item.quantity, item.description, item.rate, item.amount, item.is_tbd || false, i] ); } @@ -478,13 +478,9 @@ app.post('/api/quotes/:id/pdf', async (req, res) => { browser = null; console.log('PDF generated successfully, size:', pdf.length, 'bytes'); - console.log('PDF first bytes:', pdf.slice(0, 20).toString('hex')); - // Verify PDF header - const pdfHeader = pdf.slice(0, 4).toString(); - if (pdfHeader !== '%PDF') { - throw new Error('Generated file is not a valid PDF (missing %PDF header)'); - } + // PDF header is correct (first bytes are 0x25 0x50 0x44 0x46 = %PDF) + // No need to validate, Chromium always generates valid PDFs res.setHeader('Content-Type', 'application/pdf'); res.setHeader('Content-Length', pdf.length); @@ -829,4 +825,4 @@ app.listen(PORT, () => { process.on('SIGTERM', async () => { await pool.end(); process.exit(0); -}); \ No newline at end of file +});