diff --git a/bindTicketShelvingOld.js b/bindTicketShelvingOld.js index 75d0a7e..fdeb6ad 100644 --- a/bindTicketShelvingOld.js +++ b/bindTicketShelvingOld.js @@ -1,20 +1,18 @@ -const insert = require('./methods/bindTicketShelving'); +// const insert = require('./methods/bindTicketShelving'); const filter = require('./utilities/filter'); const select = require('./db/selectDB'); -var barcode = "A0A3B820690F"; -var shelving = "BCD";///introducida por el usuario -var collectionFk = '274286'; +// let barcode = 'A0A3B820690F'; +let shelving = 'BCD';// /introducida por el usuario +let collectionFk = '274286'; -function ticketCollection(collectionFk){//parametro collectionFk - select.select(collectionFk, function(err,data){ - if(filter.isShelving(shelving)){ - //insert.insertTicket(data, shelving,) - } - else{ - console.log("¡MATRICULA INCORRECTA!") - } +function ticketCollection(collectionFk) {// parametro collectionFk + select.select(collectionFk, function(err, data) { + if (filter.isShelving(shelving)) { + // insert.insertTicket(data, shelving,) + } else + console.log('¡MATRICULA INCORRECTA!'); }); } -ticketCollection(collectionFk); \ No newline at end of file +ticketCollection(collectionFk); diff --git a/doc/1getKey.js b/doc/1getKey.js index 16c9d41..99062bd 100644 --- a/doc/1getKey.js +++ b/doc/1getKey.js @@ -5,14 +5,14 @@ const port = 9999; app.get('/', async(req, res) => { (async() => { - const { body } = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', { + const {body} = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', { }); - let body2=JSON.parse(body) - console.log(body2.data) + let body2 = JSON.parse(body); + console.log(body2.data); res.end(body); - })(); + })(); }); app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`) -}); \ No newline at end of file + console.log(`Example app listening at http://localhost:${port}`); +}); diff --git a/doc/2login.js b/doc/2login.js index 14aebec..8ec3245 100644 --- a/doc/2login.js +++ b/doc/2login.js @@ -7,7 +7,7 @@ const port = 9999; app.get('/', async(req, res) => { (async() => { - const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/user/login', { + const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/user/login', { json: { account: config.user, loginType: 3, @@ -15,11 +15,11 @@ app.get('/', async(req, res) => { }, responseType: 'json' }); - console.log(body) + console.log(body); res.end(JSON.stringify(body)); })(); }); app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`) -}); \ No newline at end of file + console.log(`Example app listening at http://localhost:${port}`); +}); diff --git a/doc/3batchImport.js b/doc/3batchImport.js index 97fbd56..b9adcd9 100644 --- a/doc/3batchImport.js +++ b/doc/3batchImport.js @@ -1,59 +1,58 @@ const express = require('express'); const got = require('got'); const config = require('./config'); -const encrypt = require('./encrypted'); const app = express(); const port = 9999; app.get('/', async(req, res) => { (async() => { - const info = await config.info - let key = info.data.token + const info = await config.info; + let key = info.data.token; let currentUser = info.data.currentUser; (async() => { - const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { + const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { json: { agencyId: currentUser.agencyId, merchantId: currentUser.merchantId, storeId: currentUser.storeId, unitName: currentUser.unitName, itemList: [{ - attrCategory: "default", - attrName: "default", - barCode: "1000012345", - itemTitle: "Australian apple", - originalPrice: "600", - price: "6300", - productArea: "Britain", - productCode: "4151512414155", - productSku: "200001275", - }, - { - attrCategory: "default", - attrName: "default", - barCode: "5141415414312", - itemTitle: "Cavendish banana", - originalPrice: "10", - price: "8", - productArea: "Brasil", - productCode: "4151512414156", - productSku: "20001536", - promotionText: "sale" - } + attrCategory: 'default', + attrName: 'default', + barCode: '1000012345', + itemTitle: 'Australian apple', + originalPrice: '600', + price: '6300', + productArea: 'Britain', + productCode: '4151512414155', + productSku: '200001275', + }, + { + attrCategory: 'default', + attrName: 'default', + barCode: '5141415414312', + itemTitle: 'Cavendish banana', + originalPrice: '10', + price: '8', + productArea: 'Brasil', + productCode: '4151512414156', + productSku: '20001536', + promotionText: 'sale' + } ] }, responseType: 'json', headers: { - "Authorization": key + 'Authorization': key } - }) - console.log(body) - res.end(JSON.stringify(body)) + }); + console.log(body); + res.end(JSON.stringify(body)); })(); })(); }); app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`) -}); \ No newline at end of file + console.log(`Example app listening at http://localhost:${port}`); +}); diff --git a/doc/4batchDelete.js b/doc/4batchDelete.js index 01c0126..d288606 100644 --- a/doc/4batchDelete.js +++ b/doc/4batchDelete.js @@ -1,35 +1,34 @@ const express = require('express'); const got = require('got'); const config = require('./config'); -const encrypt = require('./encrypted'); const app = express(); const port = 9999; app.get('/', async(req, res) => { (async() => { - const info = await config.info + const info = await config.info; let key = info.data.token; (async() => { - const { body } = await got.delete('http://app.etiquetaselectronicas.com:9999/item/batchDeleteItem', { + const {body} = await got.delete('http://app.etiquetaselectronicas.com:9999/item/batchDeleteItem', { json: { storeId: config.storeId, list: [ - "2000123456", - "5141415414312" + '2000123456', + '5141415414312' ] }, responseType: 'json', headers: { - "Authorization": key + 'Authorization': key } - }) - console.log(body) - res.end(JSON.stringify(body)) + }); + console.log(body); + res.end(JSON.stringify(body)); })(); })(); }); app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`) -}); \ No newline at end of file + console.log(`Example app listening at http://localhost:${port}`); +}); diff --git a/doc/5batchBind.js b/doc/5batchBind.js index 1c09b75..97d6f2b 100644 --- a/doc/5batchBind.js +++ b/doc/5batchBind.js @@ -1,40 +1,39 @@ const express = require('express'); const got = require('got'); const config = require('./config'); -const encrypt = require('./encrypted'); const app = express(); const port = 9999; app.get('/', async(req, res) => { (async() => { - const info = await config.info + const info = await config.info; let key = info.data.token; (async() => { - const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/bind/batchBind', { + const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/bind/batchBind', { json: { storeId: config.storeId, tagItemBinds: [{ - eslBarcode: "A0A3B8207222", - itemBarcode: "100001234" - }, - { - eslBarcode: "A0A3B820690F", - itemBarcode: "5141415414312" - } + eslBarcode: 'A0A3B8207222', + itemBarcode: '100001234' + }, + { + eslBarcode: 'A0A3B820690F', + itemBarcode: '5141415414312' + } ] }, responseType: 'json', headers: { - "Authorization": key + 'Authorization': key } - }) - console.log(body) - res.end(JSON.stringify(body)) + }); + console.log(body); + res.end(JSON.stringify(body)); })(); })(); }); app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`) -}); \ No newline at end of file + console.log(`Example app listening at http://localhost:${port}`); +}); diff --git a/doc/encrypted.js b/doc/encrypted.js index 738ce03..f8f9d24 100644 --- a/doc/encrypted.js +++ b/doc/encrypted.js @@ -1,17 +1,16 @@ const crypto = require('crypto'); const got = require('got'); -const config = require('./config'); -const encryptPassword = async(password) => { - const { body } = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', { - }); - const publicKey=`-----BEGIN PUBLIC KEY-----\n${JSON.parse(body).data}\n-----END PUBLIC KEY-----`; - const externKey = { - key: publicKey, - padding: crypto.constants.RSA_PKCS1_PADDING - }; - let buffer = Buffer.from(password); - return crypto.publicEncrypt(externKey, buffer).toString("base64"); +const encryptPassword = async password => { + const {body} = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', { + }); + const publicKey = `-----BEGIN PUBLIC KEY-----\n${JSON.parse(body).data}\n-----END PUBLIC KEY-----`; + const externKey = { + key: publicKey, + padding: crypto.constants.RSA_PKCS1_PADDING + }; + let buffer = Buffer.from(password); + return crypto.publicEncrypt(externKey, buffer).toString('base64'); }; -exports.encryptPassword = encryptPassword; \ No newline at end of file +exports.encryptPassword = encryptPassword; diff --git a/methods/bindShelvingTag.js b/methods/bindShelvingTag.js index c74fc20..208d00a 100644 --- a/methods/bindShelvingTag.js +++ b/methods/bindShelvingTag.js @@ -6,95 +6,92 @@ const express = require('express'); const router = express.Router(); router.get('/', async(req, res) => { - ///DATOS INTRODUCIDOS POR EL USUARIO//// - var barcode = "A0A3B8224DBF"; //valido = "A0A3B82"+ 4 CARACTERES HEXADECIMALES (0-F) - var shelving = "ABC"; //valido = 3 CARACTERES LETRAS (A-Z) - var level = "4"; - ////////////////////////////////////// + // DATOS INTRODUCIDOS POR EL USUARIO + let barcode = 'A0A3B8224DBF'; // valido = "A0A3B82"+ 4 CARACTERES HEXADECIMALES (0-F) + let shelving = 'ABC'; // valido = 3 CARACTERES LETRAS (A-Z) + let level = '4'; + // //////////////////////////////////// const result = bindShelvingTag(barcode, shelving, level); - if(result == 'INVALID_PLATE'){ - res.json({message: 'MATRICULA INCORRECTA'}) - }else if (result == 'INVALID_TAG_CODE'){ - res.json({message: 'CODIGO DE ETIQUETA INCORRECTO'}) - }else{ + if (result == 'INVALID_PLATE') + res.json({message: 'MATRICULA INCORRECTA'}); + else if (result == 'INVALID_TAG_CODE') + res.json({message: 'CODIGO DE ETIQUETA INCORRECTO'}); + else res.json({message: 'SUCCESS'}); - } - }); module.exports = router; -function bindShelvingTag(barcode, shelving, level){ - if(filter.isBarcode(barcode)){ - if(filter.isShelving(shelving)){ +function bindShelvingTag(barcode, shelving, level) { + if (filter.isBarcode(barcode)) { + if (filter.isShelving(shelving)) { let shelvingId = shelving + level; insertShelving(shelvingId); bindShelving(barcode, shelvingId); insertDB.insertDB(barcode, shelving, level); - }else{ - //console.log("¡MATRICULA INCORRECTA!"); + } else { + // console.log("¡MATRICULA INCORRECTA!"); return 'INVALID_PLATE'; - } - }else{ - //console.log("¡CODIGO DE ETIQUETA INCORRECTO!") + } else { + // console.log("¡CODIGO DE ETIQUETA INCORRECTO!") return 'INVALID_TAG_CODE'; } -} - -function insertShelving(shelvingId){ - (async() => { - const info = await config.info - let key = info.data.token - let currentUser = info.data.currentUser; - (async() => { - const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { - json: { - agencyId: currentUser.agencyId, - merchantId: currentUser.merchantId, - storeId: currentUser.storeId, - unitName: currentUser.unitName, - itemList: [ - { - attrCategory: "verdnatura", - attrName: "sinTicket", - barCode: shelvingId,//Matricula + nivel - itemTitle: "Etiqueta Sin ticket", - } - ] - }, - responseType: 'json', - headers: { - "Authorization": key - } - }) - //console.log("CARRO: ",body) - })(); - })(); } -function bindShelving(barcode, shelvingId){ +function insertShelving(shelvingId) { (async() => { - const info = await config.info + const info = await config.info; let key = info.data.token; + let currentUser = info.data.currentUser; (async() => { - const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/bind/batchBind', { + const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { json: { - storeId: config.storeId, - tagItemBinds: [{ - eslBarcode: barcode, - itemBarcode: shelvingId + agencyId: currentUser.agencyId, + merchantId: currentUser.merchantId, + storeId: currentUser.storeId, + unitName: currentUser.unitName, + itemList: [ + { + attrCategory: 'verdnatura', + attrName: 'sinTicket', + barCode: shelvingId, // Matricula + nivel + itemTitle: 'Etiqueta Sin ticket', } ] }, responseType: 'json', headers: { - "Authorization": key + 'Authorization': key } - }) - //console.log("ETIQUETA: ",body) + }); + // console.log("CARRO: ",body) })(); })(); } -exports.bindShelving = bindShelving; \ No newline at end of file + +function bindShelving(barcode, shelvingId) { + (async() => { + const info = await config.info; + let key = info.data.token; + (async() => { + const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/bind/batchBind', { + json: { + storeId: config.storeId, + tagItemBinds: [{ + eslBarcode: barcode, + itemBarcode: shelvingId + } + ] + }, + responseType: 'json', + headers: { + 'Authorization': key + } + }); + // console.log("ETIQUETA: ",body) + })(); + })(); +} +exports.bindShelving = bindShelving; diff --git a/methods/bindTicketShelving.js b/methods/bindTicketShelving.js index 9de35bd..fb2d7c2 100644 --- a/methods/bindTicketShelving.js +++ b/methods/bindTicketShelving.js @@ -1,46 +1,45 @@ const express = require('express'); const router = express.Router(); -const filter = require('../utilities/filter'); +// const filter = require('../utilities/filter'); const select = require('../db/selectDB'); const maxWagon = require('../db/maxWagon'); - router.get('/:collectionFk', async(req, res) => { - //var shelving = "BCD";///introducida por el usuario O en leida de la bbdd? - //var collectionFk = '273449'; + // var shelving = "BCD";///introducida por el usuario O en leida de la bbdd? + // var collectionFk = '273449'; const collectionFk = req.params.collectionFk; ticketCollection(collectionFk); - res.json({message: 'SUCCESS'}) + res.json({message: 'SUCCESS'}); }); module.exports = router; -function ticketCollection(collectionFk){//parametro collectionFk - select.select(collectionFk, function(err,data){ - maxWagon.maxWagon(collectionFk,function(err,max){ - //aqui iria una función para pedir el numero de shelvings correspondientes - var shelving = ['ABC','DFG','HIJ'] - //if(filter.isShelving(shelving)){ - insertTicket(data, shelving, max) - //}else{ - //console.log("¡MATRICULA INCORRECTA!") - //} +function ticketCollection(collectionFk) {// parametro collectionFk + select.select(collectionFk, function(err, data) { + maxWagon.maxWagon(collectionFk, function(err, max) { + // aqui iria una función para pedir el numero de shelvings correspondientes + let shelving = ['ABC', 'DFG', 'HIJ']; + // if(filter.isShelving(shelving)){ + insertTicket(data, shelving, max); + // }else{ + // console.log("¡MATRICULA INCORRECTA!") + // } }); }); } -function insertTicket(consultaSql, shelving, max){ +function insertTicket(consultaSql, shelving, max) { const config = require('../config'); const got = require('got'); (async() => { - const info = await config.info - let key = info.data.token + const info = await config.info; + let key = info.data.token; let currentUser = info.data.currentUser; (async() => { - for(var i=0;i { - const info = await config.info - let key = info.data.token + const info = await config.info; + let key = info.data.token; let currentUser = info.data.currentUser; (async() => { - for(var i=0;i= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, "http2-wrapper": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", @@ -646,6 +821,14 @@ "resolve-alpn": "^1.0.0" } }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -679,6 +862,11 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" + }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -771,6 +959,39 @@ "yallist": "^4.0.0" } }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.46.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz", + "integrity": "sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==" + }, + "mime-types": { + "version": "2.1.29", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz", + "integrity": "sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==", + "requires": { + "mime-db": "1.46.0" + } + }, "mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -784,6 +1005,11 @@ "brace-expansion": "^1.1.7" } }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, "mysql": { "version": "2.18.1", "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz", @@ -800,11 +1026,24 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, "normalize-url": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==" }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -839,6 +1078,11 @@ "callsites": "^3.0.0" } }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -849,6 +1093,11 @@ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -864,6 +1113,15 @@ "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" }, + "proxy-addr": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.1" + } + }, "pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -878,11 +1136,32 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, "quick-lru": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==" }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -938,6 +1217,11 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, "semver": { "version": "7.3.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", @@ -946,6 +1230,49 @@ "lru-cache": "^6.0.0" } }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -1002,6 +1329,11 @@ "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", "integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A=" }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, "string-width": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", @@ -1075,6 +1407,11 @@ "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -1088,6 +1425,20 @@ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==" }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -1101,11 +1452,21 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==" }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 1bfc43d..c1b6b94 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "license": "ISC", "dependencies": { "eslint": "^7.22.0", + "eslint-config-google": "^0.14.0", + "express": "^4.17.1", "got": "^11.8.2", "mysql": "^2.18.1" } diff --git a/server.js b/server.js index 895ddd7..755c0da 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,6 @@ const port = 9999; app.use('/bindShelving', require('./methods/bindShelvingTag')); app.use('/insertTicket', require('./methods/bindTicketShelving')); - app.listen(port, () => { - console.log(`Example app listening at http://localhost:${port}`) + console.log(`Example app listening at http://localhost:${port}`); }); diff --git a/utilities/encrypted.js b/utilities/encrypted.js index f68c674..d97ab1d 100644 --- a/utilities/encrypted.js +++ b/utilities/encrypted.js @@ -1,17 +1,17 @@ const crypto = require('crypto'); const got = require('got'); -const config = require('../config'); +// const config = require('../config'); -const encryptPassword = async(password) => { - const { body } = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', { - }); - const publicKey=`-----BEGIN PUBLIC KEY-----\n${JSON.parse(body).data}\n-----END PUBLIC KEY-----`; - const externKey = { - key: publicKey, - padding: crypto.constants.RSA_PKCS1_PADDING - }; - let buffer = Buffer.from(password); - return crypto.publicEncrypt(externKey, buffer).toString("base64"); +const encryptPassword = async password => { + const {body} = await got.get('http://app.etiquetaselectronicas.com:9999/user/getErpPublicKey', { + }); + const publicKey = `-----BEGIN PUBLIC KEY-----\n${JSON.parse(body).data}\n-----END PUBLIC KEY-----`; + const externKey = { + key: publicKey, + padding: crypto.constants.RSA_PKCS1_PADDING + }; + let buffer = Buffer.from(password); + return crypto.publicEncrypt(externKey, buffer).toString('base64'); }; exports.encryptPassword = encryptPassword; diff --git a/utilities/filter.js b/utilities/filter.js index 3b5d41d..0fd72c9 100644 --- a/utilities/filter.js +++ b/utilities/filter.js @@ -1,10 +1,10 @@ -function isBarcode(toFilter){ - const exp = /^A0A3B82[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]$/ - return exp.test(toFilter) +function isBarcode(toFilter) { + const exp = /^A0A3B82[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]$/; + return exp.test(toFilter); } -function isShelving(toFilter){ - const exp = /^[A-Z][A-Z][A-Z]$/ - return exp.test(toFilter) +function isShelving(toFilter) { + const exp = /^[A-Z][A-Z][A-Z]$/; + return exp.test(toFilter); } exports.isBarcode = isBarcode; -exports.isShelving = isShelving; \ No newline at end of file +exports.isShelving = isShelving;