- 浏览: 2490509 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 434NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 297Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 379Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 339Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 420NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 365Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 294Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 214GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 395GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 281GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 268Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 268Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 255Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 241Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 238NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 229Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 521NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 232Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 324Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 323Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
nodeJS version manager 专门管理NodeJS版本和NPM版本
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
nodejs版本管理工具。可以在多个nodejs版本中进行切换,降低了升级nodejs时的成本。
今天小编就为大家分享一篇关于nodejs npm错误Error:UNKNOWN:unknown error,mkdir 'D:Developnodejsnode_global'at Error,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看...
nodejs初级教程
Build an interactive and full-featured web application from scratch using Node.js and MongoDB About This Book Configure your development environment to use Node.js and MongoDB Use Node.js to connect ...
based on nodejs as server and return a web
这是一个vue+nodejs+express+mybatis够成的一个项目案例
NodeJS
nodejs -v 10.1.0 for mac ,稳定版本
节点js 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.
,nodEjs ,nodEjs ,nodEjs ,nodEjs ,nodEjs ,nodEjs ,nodEjs ,nodEjs ,nodEjs
Productive and Fun Web Development with NodeJS and Microsoft Developer Tools
nodejs安装及环境配置
资源名称:NodeJs技术经典文档资源目录:【】Node.js开发指南_中文正版【】nodejs开发指南pdf及源码及win安装程序【】nodejs手册中文【】NodeJs教程【】umav4simple【】七天学会NodeJS【】七天学会NodeJS【】深入浅...
NodeJS开发指南
This book has complete source code with all required features of websites, registration, login, edit, delete and session management working source code with explanation, so that you can build upon it...