@alizadefaig/pos-server 1.2.8 → 1.2.10
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 +1 -1
- package/routes/common/tax.js +29 -0
- package/routes/desktop/api/printers.js +5 -0
- package/server.js +5 -1
- package/utils.js +0 -1
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';
|
package/server.js
CHANGED
|
@@ -17,7 +17,11 @@ const upload = multer();
|
|
|
17
17
|
app.use(express.json({limit: '500mb'}));
|
|
18
18
|
app.use(express.urlencoded({extended: true, limit: '500mb'}));
|
|
19
19
|
app.use(upload.any());
|
|
20
|
-
app.use(cors(
|
|
20
|
+
app.use(cors({
|
|
21
|
+
origin: '*',
|
|
22
|
+
allowedHeaders: '*',
|
|
23
|
+
methods: '*'
|
|
24
|
+
}));
|
|
21
25
|
|
|
22
26
|
|
|
23
27
|
|
package/utils.js
CHANGED
|
@@ -105,7 +105,6 @@ const socketSendByFilter = ({companyId, eventName, data, to, toId, excepts}, ser
|
|
|
105
105
|
|
|
106
106
|
function findKeyByValue(map, targetKey, targetValue) {
|
|
107
107
|
for (const item of map.values()) {
|
|
108
|
-
console.log(item);
|
|
109
108
|
if (item[targetKey] === targetValue) {
|
|
110
109
|
return item;
|
|
111
110
|
}
|