Minor fixes
- use catclient instead of catprint - fix weight being 1000x what it should be - issue auth tokens for 20 hours
This commit is contained in:
parent
7ce08921ad
commit
0e67d30c7d
21
index.js
21
index.js
@ -137,7 +137,8 @@ app.post('/toktok', (req, res) => {
|
|||||||
return res.json({message: 'This is not the way.'});
|
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);
|
const token = jwt.sign({expiration}, accessTokenSecret);
|
||||||
|
|
||||||
res.json({message: 'This is the way.', token});
|
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 qr_url = `http://lafermedumalpas.fr/chikinz/${chikinId}`;
|
||||||
const chikin = await getChikin(db, chikinId);
|
const chikin = await getChikin(db, chikinId);
|
||||||
|
const weight = chikin.weight / 1000;
|
||||||
const line0 = 'Poulet fermier bio';
|
const line0 = 'Poulet fermier bio';
|
||||||
const line1 = `${chikin.weight.toFixed(2)} kg`;
|
const line1 = `${weight.toFixed(2)} kg`;
|
||||||
|
|
||||||
const pricePerKg = 12;
|
const pricePerKg = 12;
|
||||||
const price = chikin.weight * pricePerKg;
|
const price = weight * pricePerKg;
|
||||||
const line2 = `${pricePerKg.toFixed(2)} €/kg - ${price.toFixed(2)}`;
|
const line2 = `${pricePerKg.toFixed(2)} €/kg - ${price.toFixed(2)} €`;
|
||||||
|
|
||||||
const args = ['/Users/paul/scratch/printer/catprint.py',
|
// const args = ['/Users/paul/scratch/printer/catprint.py',
|
||||||
'--template0', [qr_url, line0, line1, line2].join(';')];
|
// '--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);
|
const proc = child_process.spawn('python', args);
|
||||||
proc.stdout.on('data', data => console.log(`stdout: ${data}`));
|
proc.stdout.on('data', data => console.log(`stdout: ${data}`));
|
||||||
|
Loading…
Reference in New Issue
Block a user