@alizadefaig/pos-server 1.2.8 → 1.2.9
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/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const {socketSendByFilter, findKeyByValue} = require("../../utils");
|
|
3
|
+
const serverSocket = require("../../app/socket/server")();
|
|
4
|
+
const router = express.Router();
|
|
5
|
+
const {createProxyMiddleware, fixRequestBody} = require("http-proxy-middleware");
|
|
6
|
+
const moment = require("moment/moment");
|
|
7
|
+
|
|
8
|
+
const proxy = createProxyMiddleware({
|
|
9
|
+
target: 'http://localhost:3005',
|
|
10
|
+
router: function (req) {
|
|
11
|
+
// Подставляем URL из query или тела запроса
|
|
12
|
+
const dynamicUrl = req.query.url || req.body?.url;
|
|
13
|
+
|
|
14
|
+
if (!dynamicUrl) {
|
|
15
|
+
return null; // не будет проксировать, Express продолжит обработку
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return dynamicUrl;
|
|
19
|
+
},
|
|
20
|
+
on: {
|
|
21
|
+
proxyReq: (proxyReq, req, res, options) => {
|
|
22
|
+
return fixRequestBody(proxyReq, req);
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
router.use('/tax', proxy)
|
|
28
|
+
|
|
29
|
+
module.exports = router;
|
|
@@ -108,6 +108,11 @@ router.get('/printers.get', async (req, res) => {
|
|
|
108
108
|
})
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
+
router.get('/printers.getUsbPrinters', async (req, res) => {
|
|
112
|
+
let usbPrinters = await getUsbPrinters();
|
|
113
|
+
res.json(usbPrinters);
|
|
114
|
+
})
|
|
115
|
+
|
|
111
116
|
router.post('/printers.print', async (req, res) => {
|
|
112
117
|
const device = getPrinterDevice(req.body.printer);
|
|
113
118
|
const printMethod = req.body.print_method || 'raster';
|