diff --git a/index.js b/index.js index 710d9a7..0916403 100644 --- a/index.js +++ b/index.js @@ -137,7 +137,8 @@ app.post('/toktok', (req, res) => { return res.json({message: 'This is not the way.'}); } - const expiration = new Date().getTime() + 7200000; + // 20-hour tokens + const expiration = new Date().getTime() + 20 * 3600 * 1000; const token = jwt.sign({expiration}, accessTokenSecret); res.json({message: 'This is the way.', token}); @@ -155,15 +156,23 @@ app.post('/print', authenticateJWT, async (req, res) => { const qr_url = `http://lafermedumalpas.fr/chikinz/${chikinId}`; const chikin = await getChikin(db, chikinId); + const weight = chikin.weight / 1000; const line0 = 'Poulet fermier bio'; - const line1 = `${chikin.weight.toFixed(2)} kg`; + const line1 = `${weight.toFixed(2)} kg`; const pricePerKg = 12; - const price = chikin.weight * pricePerKg; - const line2 = `${pricePerKg.toFixed(2)} €/kg - ${price.toFixed(2)}`; + const price = weight * pricePerKg; + const line2 = `${pricePerKg.toFixed(2)} €/kg - ${price.toFixed(2)} €`; - const args = ['/Users/paul/scratch/printer/catprint.py', - '--template0', [qr_url, line0, line1, line2].join(';')]; +// const args = ['/Users/paul/scratch/printer/catprint.py', +// '--address', '0DE203E8-0E8F-4361-9E80-D9C3794612A4', +// '--template0', [qr_url, line0, line1, line2].join(';'), +// '--feed', +// ]; + const args = ['/Users/paul/scratch/printer/catclient.py', + '--template0', [qr_url, line0, line1, line2].join(';'), + '--feed', + ]; const proc = child_process.spawn('python', args); proc.stdout.on('data', data => console.log(`stdout: ${data}`));