cluster&forevercluster & forever虽然 nodejs 原生已经提供了 cluster 模块,大部分情况下可以满足我们的基本需求,但这两个模块 cluster 和 forever 都提供了更强大的功能。 cluster 及 forever 都能让你的 nodejs 应用的管理更加方便,比如启动、重启、停止你的应用。 他们也都可以保证应用的稳定性,如果你的 nodejs 程序存在错误而使进程关闭了,cluster 或 forever 都能自动重启他们,以保证 nodejs 应用零宕机。 Github 地址node_redisnode_redis是为 NodeJS 而写的 Redis client,它支持所有 Redis 命令。 使用方法var redis = require("redis"), client = redis.createClient(); client.on("error", function (err) { console.log("Error " + err); }); client.set("string key", "string val", redis.print); client.hset("hash key", "hashtest 1", "some value", redis.print); client.hset(["hash key", "hashtest 2", "some other value"], redis.print); client.hkeys("hash key", function (err, replies) { console.log(replies.length + " replies:"); replies.forEach(function (reply, i) { console.log(" " + i + ": " + reply); }); client.quit(); }); Github 地址html2jadehtml2jadehtml2jade 模块可以方便的转换现有的 HTML 到 Jade 格式。 目前仅支持 OS X 和 Linux 平台。 使用方法抓取 URL 并转换源码 html2jade http://twitter.com // 会输出到终端控制台 html2jade http://twitter.com > twitter.jade // 输出到 twitter.jade 文件转换现有 HTML 文件 html2jade mywebpage.html # 输出到 mywebpage.jade html2jade public/*.html # 转换所有 .html 文件到 .jade Github 地址node-canvasnode-canvasNodeJS 的 Canvas 实现,基于 Cairo。可以像浏览器端一样做图片处理: var Canvas = require('../lib/canvas') , Image = Canvas.Image , fs = require('fs'); var img = new Image; img.onerror = function(err){ throw err; }; img.onload = function(){ var w = img.width / 2 , h = img.height / 2 , canvas = new Canvas(w, h) , ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0, w, h, 0, 0, w, h); var out = fs.createWriteStream(__dirname + '/crop.jpg'); var stream = canvas.createJPEGStream({ bufsize : 2048, quality : 80 }); stream.pipe(out); }; img.src = __dirname + '/images/squid.png'; Github 地址:xml2jsxml2jsxml2js 基于 sax-js模块,提供简单的 xml 到 Javascript 对象的转换,如需解析 DOM ,jsdom更合适。 使用方法var fs = require('fs'), xml2js = require('xml2js'); var parser = new xml2js.Parser(); fs.readFile(__dirname + '/foo.xml', function(err, data) { parser.parseString(data, function (err, result) { console.dir(result); console.log('Done'); }); }); Github 地址mailermailerNodeJS 邮件发送模块,支持定制基于 Mustache 的模板正文。 使用方法var email = require("../lib/node_mailer"); for(var i = 0; i < 10; i++){ email.send({ host : "localhost", // smtp server hostname port : "25", // smtp server port ssl: true, // for SSL support - REQUIRES NODE v0.3.x OR HIGHER domain : "localhost", // domain used by client to identify itself to server to : "marak.squires@gmail.com", from : "obama@whitehouse.gov", subject : "node_mailer test email", body: "Hello! This is a test of the node_mailer.", authentication : "login", // auth login is supported; anything else is no auth username : "my_username", // username password : "my_password" // password }, function(err, result){ if(err){ console.log(err); } }); } Github 地址NideNideNide是一个基于Web的开源的Node.js IDE,在MIT License下开源,代码托管于GitHub。其设计思想是简单、易用。Nide最初是在一个叫做Node Knockout的48小时编程竞赛中开发产生的。
http://coreh.github.com/nide/
expressjsexpressjsExpress 是基于Node.js,高性能、一流的 web 开发框架。 Express JS 中文入门指引手册地址: http://www./tools/express-js/express-guide-reference-zh-CN.html |
|
来自: Tehero > 《Javascript》