Skip to content

Commit 35d7c87

Browse files
committed
fix fetcher
1 parent 30ed659 commit 35d7c87

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/client/fetcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async function fetchTask(c) {
1313
logger.info('Fetching Task from tools server...');
1414
try {
1515
const printersInfo = await getPrinters();
16-
const { body } = await superagent.post(`${c.server}/client/${c.token}`)
16+
const { body } = await superagent.post(`${c.server}/client/${c.token}/print`)
1717
.send({
1818
printers: global.Tools.printers,
1919
printersInfo: JSON.stringify(await printersInfo.map((p) => ({
@@ -27,7 +27,7 @@ async function fetchTask(c) {
2727
fs.writeFileSync(path.resolve(process.cwd(), 'data/printer.json'), JSON.stringify(global.Tools.printers));
2828
logger.info(`Printer set to ${global.Tools.printer}`);
2929
}
30-
if (body.code) {
30+
if (body.doc) {
3131
logger.info(`Print task ${body.doc.tid}#${body.doc._id}...`);
3232
await printFile(body.doc);
3333
await superagent.post(`${c.server}/client/${c.token}/doneprint/${body.doc._id}`);

utils.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Logger from 'reggol';
2+
3+
Logger.levels.base = process.env.DEV ? 3 : 2;
4+
Logger.targets[0].showTime = 'dd hh:mm:ss';
5+
Logger.targets[0].label = {
6+
align: 'right',
7+
width: 9,
8+
margin: 1,
9+
};
10+
11+
export * as fs from 'fs-extra';
12+
export * as yaml from 'js-yaml';
13+
export function sleep(timeout: number) {
14+
return new Promise((resolve) => {
15+
setTimeout(() => resolve(true), timeout);
16+
});
17+
}
18+
export { Logger };

0 commit comments

Comments
 (0)