Express JS – 检测电脑机器人,垃圾邮件

我试图在网上search,但没有得到这种东西。 我正在寻找expressjs / nodejs框架来识别和阻止垃圾邮件和从我的服务器抓取数据的计算机/用户。 我想保护我的服务器免受机器人。 只允许用户在那里和最好的框架。 function如 鉴定 阻止用户/ ips /networking 读取模式

如何parsing从SOAP WS的XML响应创build的JSON?

我需要帮助parsing从NodeJS中SOAP Web服务的XML响应创build的JSON。 我想要一个JSON数组notifications 。 XML如下所示: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:getNotificationsResponse xmlns:ns2="—url—"> <return> <notifications> <ackRequired>false</ackRequired> <body>Testing Notitfications</body> <created>1498798404874</created> <gpsAlt>1.0</gpsAlt> <gpsLat>1.0</gpsLat> <gpsLong>1.0</gpsLong> <messageId>253</messageId> <priority>INFORMATIONAL</priority> <senderClientId>PMC0</senderClientId> <status>SENT</status> <subject>Test Notification</subject> <updated>1498798404874</updated> <userId>1</userId> <userLogin>ipics</userLogin> </notifications> <notifications> <ackRequired>false</ackRequired> <body>Test notitfication</body> <created>1498797535714</created> <gpsAlt>0.0</gpsAlt> <gpsLat>0.0</gpsLat> <gpsLong>0.0</gpsLong> <messageId>244</messageId> <priority>HIGH</priority> <senderClientId>PMC_1234</senderClientId> <status>SENT</status> <subject>Test</subject> <updated>1498797535714</updated> <userId>1</userId> <userLogin>ipics</userLogin> </notifications> <notifications> <ackRequired>false</ackRequired> <body>Testing Notitfications</body> <created>1498794764538</created> <gpsAlt>1.0</gpsAlt> <gpsLat>1.0</gpsLat> <gpsLong>1.0</gpsLong> <messageId>239</messageId> […]

在来自API.ai的文本响应中添加新行(\ n)

在使用Node.js模块( apiai )时,我尝试在给API查询结果的API.ai文本响应中添加新行( \n ),但是当我将响应保存在callbackvariables中时似乎不起作用喜欢这个: request.on('response', function (response) { var textResponse = response.result.fulfillment.speech; // … })

用可变数据呈现HTML并将其转换为PDF

我有一个html模板页面,我想通过EJS填写数据,之后我想把这个完成的页面传递给PDF创build者; 最终的结果是我的页面充满了我的数据很好的PDF版本。 对于PDF创build者,我使用NPM html-pdf进行转换。 问题是,我不知道我可以用我的数据渲染页面,自动保存页面,然后将完成的页面传递给PDF创build者,因为PDF创build者只接受保存网页的服务器path。 也许我正在接近这个错误的方式,但下面是我目前所知道的,这确实不是很多。 任何帮助在正确的方向将不胜感激。 var renderPDF = function() { var pdf = require('html-pdf'); // pulls html page var html = fs.readFileSync('views/assets/html/render.ejs', 'utf8'); var options = {}; // creates views/test.pdf pdf.create(html, options).toFile('views/test.pdf', function(err, res) { if (err) return console.log(err); console.log(res); }); }; // this is how I usually render ejs files with data […]

阅读http获取请求的响应

我怎样才能读取从http获取的init响应? 基本上我的代码是这样的,但我不能达到这些对象。 var request = require("request") request({ url: "http://xxx/xxx/get.php?act=init&aparam=parame", method:"get", json: true }, function (error, response, body) { console.log(response.toJSON);// why i cant reach every object etc from here like this }); 回应就是这样 IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: null, […]

Visual Studio Code – 节点应用程序的启动参数被双引号包围

我有一些问题,从Visual Studio代码中启动(debugging)节点应用程序的参数。 我在launch.json使用这个configuration: // Command line arguments passed to the program. "args": [ "-cache-dig cache" ] 当启动VS Code围绕带双引号的参数时: 节点foo.js“-cache-digcaching” …这是不被这个应用程序接受。 有什么build议么?

如何使用第二节点服务器运行独立的express.js应用程序?

我想build立第二个node.js服务器来运行一个express.js应用程序,它是我当前的html(客户端)和js(服务器端)文件的一个完全独立的副本。 原因是我想在生产环境中部署当前的代码,这个代码在开发环境中处理当前的代码时,可以被团队使用,不会被closures。 我的担心是,我已经添加了我的当前node.js服务器到我的path,我不知道如果安装第二个node.js服务器我的命令启动第二台服务器将干扰我保存在node.js服务器我的pathvariables。 在问我的问题之前,有几件事要知道: 我正在使用Linux发行版的机器上工作。 我正在使用Express.js路由 我正在使用说明在以下位置安装node.js和express.js的另一个实例: www.vultr.com/docs/installing-node-js-and-express 我的问题如下: 这是否像安装节点一样简单,并按照上述链接中的说明进入新目录并从新path运行,而不将其存储在我的pathvariables中? 是否有更好更有效的方法来创build生产和开发环境,以便我的团队可以使用我已经构build的应用程序,而不会干扰当前的节点实例,同时确保在生产环境中部署应用程序的时间达到100% 一旦第二台服务器被实例化,我如何从我的terminal进行调用,以便它不打开/closures我从pathvariables运行的原始节点服务器? 考虑到上面的链接是如何从头开始和在Ubuntu上(我在CentOS – Gnome上)如何安装节点和expression,有没有更好的“如何”,我应该用来完成第二个节点,并表示安装? 当为第二个节点/快递服务器创build新的端口来侦听时,我可以select4位数的任何数字,还是有一组特定的数字可以更有效地使用? 我已经在我的开发环境中使用了Port:3000。 感谢您的指导。

错误的基于名称属性的对象数组

我有一个包含状态和名称属性的对象数组。 我想要使​​用他们的name属性使用下面的代码: array = array.sort(function(a,b){ return a.name – b.name }); 但是它不会返回正确的sorting数组。 这里有一个片段,你可以看到它的行动: var array = [{"name":"whoopsie","status":"active"},{"name":"acpid","status":"active"},{"name":"apache2","status":"active"},{"name":"apparmor","status":"active"},{"name":"apport","status":"active"},{"name":"avahi-daemon","status":"active"},{"name":"bluetooth","status":"active"},{"name":"cron","status":"active"},{"name":"cups","status":"active"},{"name":"cups-browsed","status":"active"},{"name":"dbus","status":"active"},{"name":"grub-common","status":"active"},{"name":"irqbalance","status":"active"},{"name":"kmod","status":"active"},{"name":"lightdm","status":"active"},{"name":"lvm2-lvmetad","status":"active"},{"name":"lvm2-lvmpolld","status":"active"},{"name":"apache-htcacheclean","status":"active"},{"name":"network-manager","status":"active"},{"name":"networking","status":"active"},{"name":"postfix","status":"active"},{"name":"procps","status":"active"},{"name":"resolvconf","status":"active"},{"name":"rsyslog","status":"active"},{"name":"smartmontools","status":"active"},{"name":"smbd","status":"active"},{"name":"speech-dispatcher","status":"active"},{"name":"ssh","status":"active"},{"name":"thermald","status":"active"},{"name":"tlp","status":"active"},{"name":"udev","status":"active"},{"name":"ufw","status":"active"},{"name":"lvm2-lvmpolld","status":"inactive"},{"name":"mysql","status":"active"},{"name":"alsa-utils","status":"inactive"},{"name":"x11-common","status":"inactive"},{"name":"apache-htcacheclean","status":"inactive"},{"name":"avahi-daemon","status":"inactive"},{"name":"console-setup.sh","status":"inactive"},{"name":"cryptdisks","status":"inactive"},{"name":"cryptdisks-early","status":"inactive"},{"name":"cups-browsed","status":"inactive"},{"name":"grub-common","status":"inactive"},{"name":"hwclock.sh","status":"inactive"},{"name":"kerneloops","status":"inactive"},{"name":"keyboard-setup.sh","status":"inactive"},{"name":"laptop-mode","status":"inactive"},{"name":"lvm2","status":"inactive"},{"name":"lvm2-lvmetad","status":"inactive"},{"name":"anacron","status":"inactive"},{"name":"network-manager","status":"inactive"},{"name":"nmbd","status":"inactive"},{"name":"plymouth","status":"inactive"},{"name":"plymouth-log","status":"inactive"},{"name":"pppd-dns","status":"inactive"},{"name":"prometheus","status":"inactive"},{"name":"rsync","status":"inactive"},{"name":"samba","status":"inactive"},{"name":"samba-ad-dc","status":"inactive"},{"name":"saned","status":"inactive"},{"name":"speech-dispatcher","status":"inactive"},{"name":"unattended-upgrades","status":"inactive"},{"name":"uuidd","status":"inactive"},{"name":"unattended-upgrades","status":"active"}]; array = array.sort(function (a,b) { return a.name – b.name }) console.log(array.map(function(i){ return i.name })) 这是输出: 我在nodejs中运行这个代码 [ 'whoopsie', 'unattended-upgrades', 'apache2', 'apparmor', 'apport', 'avahi-daemon', 'bluetooth', 'cron', 'cups', 'cups-browsed', 'dbus', 'grub-common', 'irqbalance', 'kmod', 'lightdm', 'lvm2-lvmetad', 'lvm2-lvmpolld', 'apache-htcacheclean', 'network-manager', 'networking', 'postfix', 'procps', […]

如何在centos 6上安装nodejs 6.x版本?

我使用的是Centos 6.9 当前nodejs版本v0.10.48 我想要安装nodejs 6.x版本 我试试 yum install -y gcc-c++ make curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash – yum install nodejs 但出现错误在这里input图像描述 如何在centos 6上安装nodejs 6.x版本?

重复的键值违反了唯一的约束 – 使用KnexJS和Postgresql

我目前正在使用KnexJS框架构build一个应用程序,该框架可以帮助我在开发中编写sqlite3,在生产中编写postgresql(用于Heroku)。 我的主要问题是,我的应用程序在我的机器上正常工作,但只要我上传到heroku它打破。 在Heroku日志中,我收到消息: { error: insert into "contracts" ("contract_desc", "contract_header", "owner_id", "signee_id") values ($1, $2, $3, $4) – duplicate key value violates unique constraint "contracts_pkey" 这使我无法将数据插入到我的数据库中。 我的Knex迁移表的设置是这样的: exports.up = function(knex, Promise) { return knex.schema.createTable('contracts', function (table) { table.increments('id').primary() table.integer('owner_id') table.integer('signee_id') table.string('contract_header') table.text('contract_desc') table.string('signature_url') table.string('date_signed') table.boolean('isSigned') }) }; exports.down = function(knex, Promise) { return knex.schema.dropTable('contracts') }; […]