Comparing version 1.0.0 to 2.0.0
const nfe2stalk = require('../lib/nfe2stalk') | ||
let options = { | ||
every: '10', | ||
fullNotify: true | ||
tempo: '10', | ||
tipoTempo: 's', | ||
notificacaoCompleta: true | ||
} | ||
nfe2stalk.monitor.iniciar(options) | ||
nfe2stalk.monitor.iti.iniciar(options) | ||
nfe2stalk.monitor.sefaz.iniciar(options) | ||
nfe2stalk.monitor.monitorar.on('alerta', (alerta) => { | ||
console.log('alerta') | ||
console.log(alerta) | ||
nfe2stalk.monitor.iti.monitorar.on('alerta', (iti) => { | ||
console.log('iti') | ||
console.log(iti) | ||
console.log('------------------------------------') | ||
}) | ||
nfe2stalk.monitor.sefaz.monitorar.on('alerta', (sefaz) => { | ||
console.log('sefaz') | ||
console.log(sefaz) | ||
console.log('------------------------------------') | ||
}) | ||
// nova versão | ||
nfe2stalk.monitor.iti.limparAlertas().then((qtAlertas) => { | ||
console.log(`${qtAlertas} removidos`) | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
}) | ||
nfe2stalk.monitor.sefaz.limparAlertas().then((qtAlertas) => { | ||
console.log(`${qtAlertas} removidos`) | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
}) |
function Nfe2Stalk () { | ||
this.resources = [] | ||
} | ||
@@ -4,0 +3,0 @@ |
@@ -1,41 +0,7 @@ | ||
const schedule = require('node-schedule') | ||
const util = require('./utils') | ||
const EventEmitter = require('events') | ||
var alerta = false | ||
const sefaz = require('./sites/sefaz') | ||
const iti = require('./sites/iti') | ||
class MyEmitter extends EventEmitter {} | ||
const monitorar = new MyEmitter() | ||
function iniciar (options) { | ||
// return new Promise((resolve, reject) => { | ||
let j = schedule.scheduleJob(`*/${options.every} * * * * *`, function () { | ||
util.crawler(function (err, info) { | ||
if (err) { | ||
return monitorar.emit('alerta', err) | ||
} | ||
// console.log(info) | ||
if (info.numero) { | ||
info.url = `http://www.nfe.fazenda.gov.br/portal/informe.aspx?ehCTG=false#${info.numero}` | ||
alerta = info | ||
return monitorar.emit('alerta', alerta) | ||
} | ||
if (options.fullNotify && !info) { | ||
alerta = false | ||
return monitorar.emit('alerta', alerta) | ||
} | ||
alerta = info | ||
monitorar.emit('alerta', alerta) | ||
}) | ||
}) | ||
// }) | ||
} | ||
module.exports = { | ||
iniciar, | ||
alerta, | ||
monitorar | ||
sefaz, | ||
iti | ||
} |
{ | ||
"name": "nfe2stalk", | ||
"description": "Lib para receber em tempo real as alterações e informes da Sefaz NF-e", | ||
"description": "Um jeito simples de receber as novidades da Sefaz NF-e", | ||
"readmeFilename": "README.md", | ||
@@ -13,3 +13,3 @@ "keywords": [ | ||
], | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"author": { | ||
@@ -16,0 +16,0 @@ "name": "Igor Souza Martins", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24890
14
371
1