@things-factory/board-service 4.3.543-alpha.0 → 4.3.563
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/index.js +6 -6
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/print.js +57 -0
- package/dist-server/controllers/print.js.map +1 -0
- package/dist-server/routers/board-print-router.js +40 -0
- package/dist-server/routers/board-print-router.js.map +1 -0
- package/dist-server/routes.js +3 -3
- package/dist-server/routes.js.map +1 -1
- package/package.json +5 -4
- package/server/controllers/index.ts +5 -5
- package/server/controllers/print.ts +52 -0
- package/server/routers/board-print-router.ts +42 -0
- package/server/routes.ts +3 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pdf = exports.headlessModel = exports.BoardFunc = void 0;
|
|
4
|
-
|
|
3
|
+
exports.pdf = exports.headlessModel = exports.BoardFunc = exports.Printer = void 0;
|
|
4
|
+
const print_1 = require("./print");
|
|
5
5
|
const label_command_1 = require("./label-command");
|
|
6
6
|
const pdf_1 = require("./pdf");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
exports.Printer = {
|
|
8
|
+
printDirect: print_1.printDirect,
|
|
9
|
+
getPrinters: print_1.getPrinters
|
|
10
|
+
};
|
|
11
11
|
exports.BoardFunc = {
|
|
12
12
|
boardToZpl: label_command_1.labelcommand,
|
|
13
13
|
boardToPdf: pdf_1.pdf
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkD;AAClD,mDAA4D;AAC5D,+BAAyC;AAE5B,QAAA,OAAO,GAAG;IACrB,WAAW,EAAX,mBAAW;IACX,WAAW,EAAX,mBAAW;CACZ,CAAA;AAEY,QAAA,SAAS,GAAG;IACvB,UAAU,EAAV,4BAAU;IACV,UAAU,EAAV,SAAU;CACX,CAAA;AAED,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,6BAA2B;AAAlB,0FAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSupportedPrintFormats = exports.getDefaultPrinterName = exports.getPrinter = exports.getPrinters = exports.printDirect = void 0;
|
|
4
|
+
try {
|
|
5
|
+
var print = require('@thiagoelg/node-printer');
|
|
6
|
+
}
|
|
7
|
+
catch (e) {
|
|
8
|
+
console.error(e);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* shoot raw data to printer
|
|
12
|
+
*
|
|
13
|
+
* @param printer Printer ID
|
|
14
|
+
* @param command Raw command
|
|
15
|
+
*/
|
|
16
|
+
async function printDirect(printer, command) {
|
|
17
|
+
print &&
|
|
18
|
+
(await print.printDirect({
|
|
19
|
+
data: command,
|
|
20
|
+
printer,
|
|
21
|
+
docname: 'RAW print',
|
|
22
|
+
success: function (jobId) {
|
|
23
|
+
console.log(`Job ID: ${jobId}`);
|
|
24
|
+
},
|
|
25
|
+
error: function (error) {
|
|
26
|
+
console.error(error);
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
exports.printDirect = printDirect;
|
|
31
|
+
/**
|
|
32
|
+
* get all installed printers
|
|
33
|
+
*/
|
|
34
|
+
function getPrinters() {
|
|
35
|
+
return (print === null || print === void 0 ? void 0 : print.getPrinters()) || [];
|
|
36
|
+
}
|
|
37
|
+
exports.getPrinters = getPrinters;
|
|
38
|
+
/**
|
|
39
|
+
* get specific printer by name
|
|
40
|
+
* @param printerName printer name
|
|
41
|
+
*/
|
|
42
|
+
function getPrinter(printerName) {
|
|
43
|
+
return print === null || print === void 0 ? void 0 : print.getPrinter(printerName);
|
|
44
|
+
}
|
|
45
|
+
exports.getPrinter = getPrinter;
|
|
46
|
+
/**
|
|
47
|
+
* get default printer name
|
|
48
|
+
*/
|
|
49
|
+
function getDefaultPrinterName() {
|
|
50
|
+
return print === null || print === void 0 ? void 0 : print.getDefaultPrinterName();
|
|
51
|
+
}
|
|
52
|
+
exports.getDefaultPrinterName = getDefaultPrinterName;
|
|
53
|
+
function getSupportedPrintFormats() {
|
|
54
|
+
return print === null || print === void 0 ? void 0 : print.getSupportedPrintFormats();
|
|
55
|
+
}
|
|
56
|
+
exports.getSupportedPrintFormats = getSupportedPrintFormats;
|
|
57
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../server/controllers/print.ts"],"names":[],"mappings":";;;AAAA,IAAI;IACF,IAAI,KAAK,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;CAC/C;AAAC,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;CACjB;AAED;;;;;GAKG;AACI,KAAK,UAAU,WAAW,CAAC,OAAO,EAAE,OAAO;IAChD,KAAK;QACH,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC;YACvB,IAAI,EAAE,OAAO;YACb,OAAO;YACP,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE,UAAU,KAAK;gBACtB,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,EAAE,CAAC,CAAA;YACjC,CAAC;YACD,KAAK,EAAE,UAAU,KAAK;gBACpB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;SACF,CAAC,CAAC,CAAA;AACP,CAAC;AAbD,kCAaC;AAED;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,EAAE,KAAI,EAAE,CAAA;AACnC,CAAC;AAFD,kCAEC;AAED;;;GAGG;AACH,SAAgB,UAAU,CAAC,WAAW;IACpC,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,CAAC,WAAW,CAAC,CAAA;AACvC,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,qBAAqB;IACnC,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,qBAAqB,EAAE,CAAA;AACvC,CAAC;AAFD,sDAEC;AAED,SAAgB,wBAAwB;IACtC,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,wBAAwB,EAAE,CAAA;AAC1C,CAAC;AAFD,4DAEC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.boardPrintRouter = void 0;
|
|
7
|
+
const koa_router_1 = __importDefault(require("koa-router"));
|
|
8
|
+
const label_command_1 = require("../controllers/label-command");
|
|
9
|
+
const print_1 = require("../controllers/print");
|
|
10
|
+
exports.boardPrintRouter = new koa_router_1.default();
|
|
11
|
+
/**
|
|
12
|
+
* ?printerId=printer_id&data=grf_string
|
|
13
|
+
*/
|
|
14
|
+
exports.boardPrintRouter.get('/print', async (context, next) => {
|
|
15
|
+
const { domain } = context.state;
|
|
16
|
+
let data = Object.keys(context.query).length ? context.query : null;
|
|
17
|
+
context.body = await (0, print_1.printDirect)(data.printerId, data.data);
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* { printerId: 'printer driver ID', data: 'grf string' }
|
|
21
|
+
*/
|
|
22
|
+
exports.boardPrintRouter.post('/print', async (context, next) => {
|
|
23
|
+
const { domain } = context.state;
|
|
24
|
+
let params = context.request.body;
|
|
25
|
+
context.type = 'text/plain';
|
|
26
|
+
context.body = await (0, print_1.printDirect)(params.printerId, params.data);
|
|
27
|
+
});
|
|
28
|
+
exports.boardPrintRouter.get('/print-label/:id', async (context, next) => {
|
|
29
|
+
const { domain } = context.state;
|
|
30
|
+
const { id } = context.params;
|
|
31
|
+
let data = Object.keys(context.query).length ? context.query : null;
|
|
32
|
+
let orientation = data && data.orientation;
|
|
33
|
+
let mirror = data && data.mirror;
|
|
34
|
+
let upsideDown = data && data.upsideDown;
|
|
35
|
+
let grf = await (0, label_command_1.labelcommand)({ id, data, orientation, mirror, upsideDown, context });
|
|
36
|
+
context.type = 'text/plain';
|
|
37
|
+
// TODO: 동기화
|
|
38
|
+
context.body = (0, print_1.printDirect)(data.printerId, grf);
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=board-print-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-print-router.js","sourceRoot":"","sources":["../../server/routers/board-print-router.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAE/B,gEAA2D;AAC3D,gDAAkD;AAErC,QAAA,gBAAgB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE5C;;GAEG;AACH,wBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACrD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;IAEnE,OAAO,CAAC,IAAI,GAAG,MAAM,IAAA,mBAAW,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;AAC7D,CAAC,CAAC,CAAA;AAEF;;GAEG;AACH,wBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACtD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,IAAI,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAEjC,OAAO,CAAC,IAAI,GAAG,YAAY,CAAA;IAC3B,OAAO,CAAC,IAAI,GAAG,MAAM,IAAA,mBAAW,EAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;AACjE,CAAC,CAAC,CAAA;AAEF,wBAAgB,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IAC7B,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;IAEnE,IAAI,WAAW,GAAG,IAAI,IAAI,IAAI,CAAC,WAAW,CAAA;IAC1C,IAAI,MAAM,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,CAAA;IAChC,IAAI,UAAU,GAAG,IAAI,IAAI,IAAI,CAAC,UAAU,CAAA;IACxC,IAAI,GAAG,GAAG,MAAM,IAAA,4BAAY,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAS,CAAC,CAAA;IAE3F,OAAO,CAAC,IAAI,GAAG,YAAY,CAAA;IAC3B,YAAY;IACZ,OAAO,CAAC,IAAI,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA"}
|
package/dist-server/routes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const board_print_router_1 = require("./routers/board-print-router");
|
|
4
4
|
const env_1 = require("@things-factory/env");
|
|
5
5
|
const headless_pool_for_board_1 = require("./controllers/headless-pool-for-board");
|
|
6
6
|
const headless_pool_for_label_1 = require("./controllers/headless-pool-for-label");
|
|
@@ -14,11 +14,11 @@ process.on('bootstrap-module-global-public-route', (app, domainGlobalPublicRoute
|
|
|
14
14
|
});
|
|
15
15
|
process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
|
|
16
16
|
if (isPathBaseDomain) {
|
|
17
|
-
|
|
17
|
+
domainPrivateRouter.use('/domain/:domain', board_print_router_1.boardPrintRouter.routes(), board_print_router_1.boardPrintRouter.allowedMethods());
|
|
18
18
|
domainPrivateRouter.use('/domain/:domain', standalone_board_service_router_1.standaloneBoardServiceRouter.routes(), standalone_board_service_router_1.standaloneBoardServiceRouter.allowedMethods());
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
|
|
21
|
+
domainPrivateRouter.use('', board_print_router_1.boardPrintRouter.routes(), board_print_router_1.boardPrintRouter.allowedMethods());
|
|
22
22
|
domainPrivateRouter.use('', standalone_board_service_router_1.standaloneBoardServiceRouter.routes(), standalone_board_service_router_1.standaloneBoardServiceRouter.allowedMethods());
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,qEAA+D;AAC/D,6CAA4C;AAC5C,mFAAkG;AAClG,mFAAkG;AAClG,qFAA8E;AAC9E,+FAAwF;AAExF,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAE7F,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,wBAAwB,EAAE,EAAE;IAC1F,IAAA,yCAAuB,GAAE,CAAA;IACzB,IAAA,yCAAuB,GAAE,CAAA;IACzB,wBAAwB,CAAC,GAAG,CAAC,EAAE,EAAE,oDAAuB,CAAC,MAAM,EAAE,EAAE,oDAAuB,CAAC,cAAc,EAAE,CAAC,CAAA;AAC9G,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,IAAI,gBAAgB,EAAE;QACpB,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,EAAE,qCAAgB,CAAC,MAAM,EAAE,EAAE,qCAAgB,CAAC,cAAc,EAAE,CAAC,CAAA;QACxG,mBAAmB,CAAC,GAAG,CACrB,iBAAiB,EACjB,8DAA4B,CAAC,MAAM,EAAE,EACrC,8DAA4B,CAAC,cAAc,EAAE,CAC9C,CAAA;KACF;SAAM;QACL,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,qCAAgB,CAAC,MAAM,EAAE,EAAE,qCAAgB,CAAC,cAAc,EAAE,CAAC,CAAA;QACzF,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,8DAA4B,CAAC,MAAM,EAAE,EAAE,8DAA4B,CAAC,cAAc,EAAE,CAAC,CAAA;KAClH;AACH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/board-service",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.563",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -23,16 +23,17 @@
|
|
|
23
23
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@things-factory/auth-base": "^4.3.
|
|
27
|
-
"@things-factory/font-base": "^4.3.
|
|
26
|
+
"@things-factory/auth-base": "^4.3.563",
|
|
27
|
+
"@things-factory/font-base": "^4.3.563",
|
|
28
28
|
"content-disposition": "^0.5.3",
|
|
29
29
|
"generic-pool": "^3.8.2"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
+
"@thiagoelg/node-printer": "0.5.3",
|
|
32
33
|
"puppeteer": "^13.1.3"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/puppeteer": "^5.4.4"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "6d56d68332b0b0b9ce496bbfda1c10e837e61e5b"
|
|
38
39
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { printDirect, getPrinters } from './print'
|
|
2
2
|
import { labelcommand as boardToZpl } from './label-command'
|
|
3
3
|
import { pdf as boardToPdf } from './pdf'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const Printer = {
|
|
6
|
+
printDirect,
|
|
7
|
+
getPrinters
|
|
8
|
+
}
|
|
9
9
|
|
|
10
10
|
export const BoardFunc = {
|
|
11
11
|
boardToZpl,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
try {
|
|
2
|
+
var print = require('@thiagoelg/node-printer')
|
|
3
|
+
} catch (e) {
|
|
4
|
+
console.error(e)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* shoot raw data to printer
|
|
9
|
+
*
|
|
10
|
+
* @param printer Printer ID
|
|
11
|
+
* @param command Raw command
|
|
12
|
+
*/
|
|
13
|
+
export async function printDirect(printer, command) {
|
|
14
|
+
print &&
|
|
15
|
+
(await print.printDirect({
|
|
16
|
+
data: command,
|
|
17
|
+
printer,
|
|
18
|
+
docname: 'RAW print',
|
|
19
|
+
success: function (jobId) {
|
|
20
|
+
console.log(`Job ID: ${jobId}`)
|
|
21
|
+
},
|
|
22
|
+
error: function (error) {
|
|
23
|
+
console.error(error)
|
|
24
|
+
}
|
|
25
|
+
}))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* get all installed printers
|
|
30
|
+
*/
|
|
31
|
+
export function getPrinters() {
|
|
32
|
+
return print?.getPrinters() || []
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* get specific printer by name
|
|
37
|
+
* @param printerName printer name
|
|
38
|
+
*/
|
|
39
|
+
export function getPrinter(printerName) {
|
|
40
|
+
return print?.getPrinter(printerName)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* get default printer name
|
|
45
|
+
*/
|
|
46
|
+
export function getDefaultPrinterName() {
|
|
47
|
+
return print?.getDefaultPrinterName()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function getSupportedPrintFormats() {
|
|
51
|
+
return print?.getSupportedPrintFormats()
|
|
52
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Router from 'koa-router'
|
|
2
|
+
|
|
3
|
+
import { labelcommand } from '../controllers/label-command'
|
|
4
|
+
import { printDirect } from '../controllers/print'
|
|
5
|
+
|
|
6
|
+
export const boardPrintRouter = new Router()
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ?printerId=printer_id&data=grf_string
|
|
10
|
+
*/
|
|
11
|
+
boardPrintRouter.get('/print', async (context, next) => {
|
|
12
|
+
const { domain } = context.state
|
|
13
|
+
let data = Object.keys(context.query).length ? context.query : null
|
|
14
|
+
|
|
15
|
+
context.body = await printDirect(data.printerId, data.data)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* { printerId: 'printer driver ID', data: 'grf string' }
|
|
20
|
+
*/
|
|
21
|
+
boardPrintRouter.post('/print', async (context, next) => {
|
|
22
|
+
const { domain } = context.state
|
|
23
|
+
let params = context.request.body
|
|
24
|
+
|
|
25
|
+
context.type = 'text/plain'
|
|
26
|
+
context.body = await printDirect(params.printerId, params.data)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
boardPrintRouter.get('/print-label/:id', async (context, next) => {
|
|
30
|
+
const { domain } = context.state
|
|
31
|
+
const { id } = context.params
|
|
32
|
+
let data = Object.keys(context.query).length ? context.query : null
|
|
33
|
+
|
|
34
|
+
let orientation = data && data.orientation
|
|
35
|
+
let mirror = data && data.mirror
|
|
36
|
+
let upsideDown = data && data.upsideDown
|
|
37
|
+
let grf = await labelcommand({ id, data, orientation, mirror, upsideDown, context } as any)
|
|
38
|
+
|
|
39
|
+
context.type = 'text/plain'
|
|
40
|
+
// TODO: 동기화
|
|
41
|
+
context.body = printDirect(data.printerId, grf)
|
|
42
|
+
})
|
package/server/routes.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { boardPrintRouter } from './routers/board-print-router'
|
|
2
2
|
import { config } from '@things-factory/env'
|
|
3
|
-
|
|
4
3
|
import { getHeadlessPool as getHeadlessPoolForBoard } from './controllers/headless-pool-for-board'
|
|
5
4
|
import { getHeadlessPool as getHeadlessPoolForLabel } from './controllers/headless-pool-for-label'
|
|
6
5
|
import { internalBoardViewRouter } from './routers/internal-board-view-router'
|
|
@@ -16,14 +15,14 @@ process.on('bootstrap-module-global-public-route' as any, (app, domainGlobalPubl
|
|
|
16
15
|
|
|
17
16
|
process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
|
|
18
17
|
if (isPathBaseDomain) {
|
|
19
|
-
|
|
18
|
+
domainPrivateRouter.use('/domain/:domain', boardPrintRouter.routes(), boardPrintRouter.allowedMethods())
|
|
20
19
|
domainPrivateRouter.use(
|
|
21
20
|
'/domain/:domain',
|
|
22
21
|
standaloneBoardServiceRouter.routes(),
|
|
23
22
|
standaloneBoardServiceRouter.allowedMethods()
|
|
24
23
|
)
|
|
25
24
|
} else {
|
|
26
|
-
|
|
25
|
+
domainPrivateRouter.use('', boardPrintRouter.routes(), boardPrintRouter.allowedMethods())
|
|
27
26
|
domainPrivateRouter.use('', standaloneBoardServiceRouter.routes(), standaloneBoardServiceRouter.allowedMethods())
|
|
28
27
|
}
|
|
29
28
|
})
|