- 浏览: 2543464 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
NodeJS Version Upgrade 5.1.0 and Error Handling
1 Version Upgrade
4.2.2 on Local Mac OS
https://nodejs.org/dist/v4.2.2/
I like to build all these things on my own server. Download the source version.
> wget https://nodejs.org/dist/v4.2.2/node-v4.2.2.tar.gz
> ./configure --prefix=/Users/carl/tool/node-v4.2.2
Make and make install there. Add it to the class path.
5.1.0 on Local Mac OS
https://nodejs.org/dist/v5.1.0/
> wget https://nodejs.org/dist/v5.1.0/node-v5.1.0.tar.gz
> ./configure --prefix=/Users/carl/tool/node-v5.1.0
Do the same thing as 4.2.2.
> node --version && npm --version
v5.1.0
3.3.12
5.1.0 on CentOS/Linux
Prepare the build env
> sudo yum groupinstall "Development Tools"
Same thing as on MAC
Add things to the path as follow:
>vi ~/.bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin
JAVA_HOME=/opt/jdk1.8.0_60
export JAVA_HOME
JRE_HOME=/opt/jdk1.8.0_60/jre
export JRE_HOME
PATH=$PATH:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin
PATH=$PATH:/opt/sbt/bin
PATH=$PATH:/opt/node/bin
export PATH
Done
> node --version && npm --version
v5.1.0
3.3.12
5.1.0 on Ubuntu System
Same as on MAC OS
5.1.0 on RaspberryPi
Currently version is as follow:
> node --version && npm --version
v0.12.7
2.11.3
Check OS version
> uname -a
Linux raspberrypi1 4.1.7+ #817 PREEMPT Sat Sep 19 15:25:36 BST 2015 armv6l GNU/Linux
> uname -a
Linux raspberrypi2 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux
Oh, my different raspberryPis are different.
On ARMV61
> wget https://nodejs.org/dist/v5.1.0/node-v5.1.0-linux-armv6l.tar.gz
Put it in the working directory
> mv node-v5.1.0-linux-armv6l ~/tool/node-v5.1.0
> sudo ln -s /home/carl/tool/node-v5.1.0 /opt/node-v5.1.0
> sudo ln -s /opt/node-v5.1.0 /opt/node
Add that node to the path, then check the version
> node --version && npm --version
v5.1.0
3.3.12
On ARMV71
> wget https://nodejs.org/dist/v5.1.0/node-v5.1.0-linux-armv7l.tar.gz
Same thing as On ARMV61
> node --version && npm --version
v5.1.0
3.3.12
2 Error Handling
For example:
/*jslint node: true */
'use strict';
var ContextIO = require('contextio');
var HashMap = require('hashmap').HashMap;
var _ = require('../underscore');
var services = null;
var cxtioClient = null;
var jobsFilter = null;
var resumesFilter = null;
module.exports = {
init: init,
fetchEmailsWithFilter: fetchEmailsWithFilter,
fetchAttachmentLink: fetchAttachmentLink,
fetchMailContent: fetchMailContent,
fetchResumesByAccountCode: fetchResumesByAccountCode,
fetchJobsByAccountCode: fetchJobsByAccountCode,
fetchAccountInfoByEmail: fetchAccountInfoByEmail
};
function init(myServices) {
services = myServices;
var logger = services.get('logger');
var config = services.get('config');
logger.info("EmailScan - initConnection ---------------");
logger.info(config.data.contextio);
cxtioClient = new ContextIO.Client(config.data.contextio.version, config.data.contextio.endpoint, config.data.contextio.security);
jobsFilter = config.data.contextio.jobsFilter;
resumesFilter = config.data.contextio.resumesFilter;
//todo: log this twice?
logger.info("EmailScan - initConnection ---------------");
}
function fetchEmailsWithFilter(accountCode, filter, callback) {
var logger = services.get('logger');
logger.trace("EmailScan - fetchEmailsWithFilter - accountCode = " + accountCode);
logger.trace("EmailScan - fetchEmailsWithFilter - filter = " + JSON.stringify(filter));
cxtioClient
.accounts(accountCode)
.messages()
.get(filter, function (err, data) {
if (err) {
logger.error("EmailScan - fetchEmailsWithFilter - fail to fetch the messages.");
callback(err, []);
return;
}
if (!data) {
var warning_message = "EmailScan - fetchEmailsWithFilter - fail to fetch any messages with filter = " + JSON.stringify(filter);
logger.warn(warning_message);
callback(null, []);
}
if (data.statusCode !== 200) {
handleNotOk(data, logger, callback);
return;
}
var msgBody = data.body;
logger.trace("EmailScan - fetchEmailsWithFilter - get the messages info with filter = " + JSON.stringify(filter));
logger.trace("EmailScan - fetchEmailsWithFilter - get response info = " + JSON.stringify(data));
logger.trace("EmailScan - fetchEmailsWithFilter - get message body = " + JSON.stringify(msgBody));
if (msgBody.length < 1) {
var warning_msg = "EmailScan - fetchEmailsWithFilter - fail to fetch any messages with filter = " + JSON.stringify(filter);
logger.warn(warning_msg);
callback(null, []);
return;
}
callback(null, msgBody);
});
}
function handleNotOk (data, logger, callback) {
//error handle, handle the error
logger.error("Unsuccessful response handle " + JSON.stringify(data));
var statusCode = 500;
if (data.statusCode !== undefined) {
statusCode = data.statusCode;
}
var err_obj = {"statusCode": statusCode, "message": data.body};
callback(err_obj, null);
}
I like the idea that my colleague change the exports part. Error Handling on the express.io controller
/*jslint node: true */
'use strict';
var HashMap = require('hashmap').HashMap;
var services = null;
module.exports = {
getAccountByEmail : function(req, res) {
//services
var emailscan = services.get('emailscan');
var logger = services.get('logger');
//params
var email = req.params.email;
emailscan.fetchAccountInfoByEmail(email, function(err, account){
if(err){
res.status(err.statusCode).json(err.message);
return ;
}
if(account === undefined || account === null){
res.status(404).json({ "type":"error", "value":"The email[" + email + "] is not valid!"});
return ;
}
logger.debug("account info = " + account.id);
res.json(account);
return ;
});
},
init : function(myservices){
services = myservices;
}
};
References:
http://sillycat.iteye.com/blog/2256088
1 Version Upgrade
4.2.2 on Local Mac OS
https://nodejs.org/dist/v4.2.2/
I like to build all these things on my own server. Download the source version.
> wget https://nodejs.org/dist/v4.2.2/node-v4.2.2.tar.gz
> ./configure --prefix=/Users/carl/tool/node-v4.2.2
Make and make install there. Add it to the class path.
5.1.0 on Local Mac OS
https://nodejs.org/dist/v5.1.0/
> wget https://nodejs.org/dist/v5.1.0/node-v5.1.0.tar.gz
> ./configure --prefix=/Users/carl/tool/node-v5.1.0
Do the same thing as 4.2.2.
> node --version && npm --version
v5.1.0
3.3.12
5.1.0 on CentOS/Linux
Prepare the build env
> sudo yum groupinstall "Development Tools"
Same thing as on MAC
Add things to the path as follow:
>vi ~/.bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin
JAVA_HOME=/opt/jdk1.8.0_60
export JAVA_HOME
JRE_HOME=/opt/jdk1.8.0_60/jre
export JRE_HOME
PATH=$PATH:/opt/jdk1.8.0_60/bin:/opt/jdk1.8.0_60/jre/bin
PATH=$PATH:/opt/sbt/bin
PATH=$PATH:/opt/node/bin
export PATH
Done
> node --version && npm --version
v5.1.0
3.3.12
5.1.0 on Ubuntu System
Same as on MAC OS
5.1.0 on RaspberryPi
Currently version is as follow:
> node --version && npm --version
v0.12.7
2.11.3
Check OS version
> uname -a
Linux raspberrypi1 4.1.7+ #817 PREEMPT Sat Sep 19 15:25:36 BST 2015 armv6l GNU/Linux
> uname -a
Linux raspberrypi2 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux
Oh, my different raspberryPis are different.
On ARMV61
> wget https://nodejs.org/dist/v5.1.0/node-v5.1.0-linux-armv6l.tar.gz
Put it in the working directory
> mv node-v5.1.0-linux-armv6l ~/tool/node-v5.1.0
> sudo ln -s /home/carl/tool/node-v5.1.0 /opt/node-v5.1.0
> sudo ln -s /opt/node-v5.1.0 /opt/node
Add that node to the path, then check the version
> node --version && npm --version
v5.1.0
3.3.12
On ARMV71
> wget https://nodejs.org/dist/v5.1.0/node-v5.1.0-linux-armv7l.tar.gz
Same thing as On ARMV61
> node --version && npm --version
v5.1.0
3.3.12
2 Error Handling
For example:
/*jslint node: true */
'use strict';
var ContextIO = require('contextio');
var HashMap = require('hashmap').HashMap;
var _ = require('../underscore');
var services = null;
var cxtioClient = null;
var jobsFilter = null;
var resumesFilter = null;
module.exports = {
init: init,
fetchEmailsWithFilter: fetchEmailsWithFilter,
fetchAttachmentLink: fetchAttachmentLink,
fetchMailContent: fetchMailContent,
fetchResumesByAccountCode: fetchResumesByAccountCode,
fetchJobsByAccountCode: fetchJobsByAccountCode,
fetchAccountInfoByEmail: fetchAccountInfoByEmail
};
function init(myServices) {
services = myServices;
var logger = services.get('logger');
var config = services.get('config');
logger.info("EmailScan - initConnection ---------------");
logger.info(config.data.contextio);
cxtioClient = new ContextIO.Client(config.data.contextio.version, config.data.contextio.endpoint, config.data.contextio.security);
jobsFilter = config.data.contextio.jobsFilter;
resumesFilter = config.data.contextio.resumesFilter;
//todo: log this twice?
logger.info("EmailScan - initConnection ---------------");
}
function fetchEmailsWithFilter(accountCode, filter, callback) {
var logger = services.get('logger');
logger.trace("EmailScan - fetchEmailsWithFilter - accountCode = " + accountCode);
logger.trace("EmailScan - fetchEmailsWithFilter - filter = " + JSON.stringify(filter));
cxtioClient
.accounts(accountCode)
.messages()
.get(filter, function (err, data) {
if (err) {
logger.error("EmailScan - fetchEmailsWithFilter - fail to fetch the messages.");
callback(err, []);
return;
}
if (!data) {
var warning_message = "EmailScan - fetchEmailsWithFilter - fail to fetch any messages with filter = " + JSON.stringify(filter);
logger.warn(warning_message);
callback(null, []);
}
if (data.statusCode !== 200) {
handleNotOk(data, logger, callback);
return;
}
var msgBody = data.body;
logger.trace("EmailScan - fetchEmailsWithFilter - get the messages info with filter = " + JSON.stringify(filter));
logger.trace("EmailScan - fetchEmailsWithFilter - get response info = " + JSON.stringify(data));
logger.trace("EmailScan - fetchEmailsWithFilter - get message body = " + JSON.stringify(msgBody));
if (msgBody.length < 1) {
var warning_msg = "EmailScan - fetchEmailsWithFilter - fail to fetch any messages with filter = " + JSON.stringify(filter);
logger.warn(warning_msg);
callback(null, []);
return;
}
callback(null, msgBody);
});
}
function handleNotOk (data, logger, callback) {
//error handle, handle the error
logger.error("Unsuccessful response handle " + JSON.stringify(data));
var statusCode = 500;
if (data.statusCode !== undefined) {
statusCode = data.statusCode;
}
var err_obj = {"statusCode": statusCode, "message": data.body};
callback(err_obj, null);
}
I like the idea that my colleague change the exports part. Error Handling on the express.io controller
/*jslint node: true */
'use strict';
var HashMap = require('hashmap').HashMap;
var services = null;
module.exports = {
getAccountByEmail : function(req, res) {
//services
var emailscan = services.get('emailscan');
var logger = services.get('logger');
//params
var email = req.params.email;
emailscan.fetchAccountInfoByEmail(email, function(err, account){
if(err){
res.status(err.statusCode).json(err.message);
return ;
}
if(account === undefined || account === null){
res.status(404).json({ "type":"error", "value":"The email[" + email + "] is not valid!"});
return ;
}
logger.debug("account info = " + account.id);
res.json(account);
return ;
});
},
init : function(myservices){
services = myservices;
}
};
References:
http://sillycat.iteye.com/blog/2256088
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 468NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 330Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 430Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 377Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 469NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 415Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 332Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 243GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 446GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 321GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 307Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 313Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 288Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 303Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 282NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 258Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 566NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 258Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 362Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 366Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
今天小编就为大家分享一篇关于nodejs npm错误Error:UNKNOWN:unknown error,mkdir 'D:Developnodejsnode_global'at Error,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看...
nodejs初级教程
nodejs14.9.0
Nodejs版本管理器(nvm安装包)
nodejs -v 10.1.0 for mac ,稳定版本
节点js NodeJS示例项目
NodeJS是一种基于Chrome V8引擎的JavaScript运行环境,它允许开发者在服务器端使用JavaScript进行编程。这个"NodeJS学习笔记和代码"的压缩包显然包含了帮助初学者掌握NodeJS基础知识和实践技能的所有必要资料。 ...
nodejs 搭建oauth服务器的代码 Install nodejs and npm and then, simply run npm install and npm start. The server should now be running at http://localhost:3000.
player.on('error', (err) => console.error('An error occurred:', err)); ``` ### 进阶功能 - **音乐库管理**: 可以扩展播放器,使其支持音乐库管理,包括搜索、排序、播放列表等功能。 - **界面集成**: 将...
NodeJS是一种基于Chrome V8引擎的JavaScript运行环境,它允许开发者在服务器端使用JavaScript进行编程,从而打破了JavaScript只能在浏览器中运行的传统。本"NodeJS整理手册文档"旨在为对NodeJS感兴趣的朋友们提供一...
NodeJS是一种基于Chrome V8引擎的JavaScript运行环境,它允许开发者使用JavaScript进行服务器端编程,打破了JavaScript只能在浏览器中运行的传统。本指南将深入探讨NodeJS的核心概念、开发工具、模块系统、网络编程...
Idea 配置前端 Web Nodejs 项目 Idea 配置前端 Web Nodejs 项目是指在 IntelliJ IDEA 集成开发环境中配置 Nodejs 项目的步骤。下面我们将详细讲解配置的步骤和相关知识点。 Idea 配置 Nodejs 项目 首先,我们需要...
资源名称:NodeJs技术经典文档资源目录:【】Node.js开发指南_中文正版【】nodejs开发指南pdf及源码及win安装程序【】nodejs手册中文【】NodeJs教程【】umav4simple【】七天学会NodeJS【】七天学会NodeJS【】深入浅...
nodejs视频教程,可以快速帮助你入门nodejs开发中,nodejs不错哦
NodeJS 是一个基于 Chrome V8 引擎的 JavaScript 运行环境,它让开发者能够在服务器端使用 JavaScript 进行编程,极大地推动了全栈开发的流行。NodeJS 的设计思想是事件驱动、非阻塞 I/O 模型,这使得它在处理高并发...
NodeJS中文文档精编.pdf 全文免费 NodeJS是 JavaScript 运行时环境,可以让 JavaScript 代码在服务器端执行。NodeJS 实际上是对 ES 标准的一个实现,同时 Node 也是一个 JS 引擎。 Node 只对 ES 标准进行了实现,...