Initial commit: Epson ePOS Node backend + Vue3 UI (printer matricial2)
This commit is contained in:
19
scripts/tests/common.js
Normal file
19
scripts/tests/common.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const axios = require('axios');
|
||||
|
||||
const baseURL = process.env.TEST_BASE_URL || 'http://localhost:3000';
|
||||
const client = axios.create({ baseURL, timeout: 120000 });
|
||||
|
||||
async function post(path, body) {
|
||||
const res = await client.post(path, body);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
function ensureOk(data, stepName) {
|
||||
if (!data || data.ok !== true) {
|
||||
const msg = `Printer did not confirm success on step: ${stepName} -> ${JSON.stringify(data)}`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { post, ensureOk };
|
||||
|
||||
Reference in New Issue
Block a user