分享

NodeJS 常用模块推荐

 Tehero 2015-06-30

 cluster&forever

cluster & forever

虽然 nodejs 原生已经提供了 cluster 模块,大部分情况下可以满足我们的基本需求,但这两个模块 cluster 和 forever 都提供了更强大的功能。

cluster 及 forever 都能让你的 nodejs 应用的管理更加方便,比如启动、重启、停止你的应用。

他们也都可以保证应用的稳定性,如果你的 nodejs 程序存在错误而使进程关闭了,cluster 或 forever 都能自动重启他们,以保证 nodejs 应用零宕机。

Github 地址

https://github.com/nodejitsu/forever

https://github.com/LearnBoost/cluster

2 条评论·一回·2012-03-24 17:47

 Geddy

Geddy

Geddy 是一个用于 NodeJS 的 web 开发框架,遵循 MVC,其目标是易用、模块化和高性能。

主要功能

  • 强大、灵活的路由功能
  • 简单易用,基于资源(resource-based)的路由
  • 附有 app 和 resource 生成器
  • 内容协商(Content-negotiation)
  • session 支持
  • 模板(EJS)、局部视图(partial)支持
  • 完全的非阻塞

有兴趣的可以去看一下它的详细介绍,一回觉得 geddy 是一款非常不错的 web 开发框架,除了 express 开发者又多了一种选择。

Github 地址

https://github.com/mde/geddy

1 条评论·一回·2012-03-21 15:24

 node-dev

node-dev

node-dev 模块是一个开发工具,当你的 js 文件修改保存后,他会自动重启服务进程,嫌 CTRL + C / up / down 费劲的同学可以尝试用它减轻开发调试的烦恼。

另外它还支持桌面提醒

使用方法

node-dev --debug app.js

Github 地址

https://github.com/fgnass/node-dev

4 条评论·一回·2012-03-20 05:13

 node_redis

node_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 地址

https://github.com/mranney/node_redis

添加评论·一回·2012-03-19 21:28

 html2jade

html2jade

html2jade 模块可以方便的转换现有的 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 地址

https://github.com/donpark/html2jade

添加评论·一回·2012-03-16 15:19

 node-canvas

node-canvas

NodeJS 的 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 地址:

https://github.com/LearnBoost/node-canvas

1 条评论·一回·2012-03-07 15:14

 xml2js

xml2js

xml2js 基于 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 地址

https://github.com/Leonidas-from-XIV/node-xml2js

添加评论·一回·2012-03-07 15:10

 mailer

mailer

NodeJS 邮件发送模块,支持定制基于 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 地址

https://github.com/Marak/node_mailer

添加评论·一回·2012-03-07 15:09

 Nide

Nide

Nide是一个基于Web的开源的Node.js IDE,在MIT License下开源,代码托管于GitHub。其设计思想是简单、易用。Nide最初是在一个叫做Node Knockout的48小时编程竞赛中开发产生的。


http://coreh.github.com/nide/


Nide当前具有的一些功能/特性:

  • 项目树显示。
  • 文件操作(创建/删除/重命名文件及文件夹,隐藏/显示隐藏文件)。
  • 代码编辑语法高亮功能。
  • OS X Lion风格的自动保存功能。
  • OS X Lion风格的版本管理,具有恢复及同时进行多个编辑操作功能。
  • 即时的项目树过滤(使用正则表达式)。
  • 集成NPM(可显示当前已安装包,添加/移除包)。
  • 类似TextMate的漂亮的界面。
  • 可浏览Node.js文档。

2 条评论·天猪·2012-03-06 13:21

 jsdom

jsdom

W3C DOM 的 Javascript 实现。

Github 地址:

http://github.com/tmpvar/jsdom/issues

添加评论·一回·2012-03-06 13:08

 Dox

Dox

兼容 Markdown, JSDoc 格式的文档生成器。

Github 地址:

https://github.com/visionmedia/dox

添加评论·一回·2012-03-06 13:04

 Jade

Jade

Jade 模板引擎,是 express 默认的模板引擎。

Github 地址:

https://github.com/visionmedia/jade

1 条评论·一回·2012-03-06 13:00

 

适合构建跨浏览器的实时应用,提供类似 WebSockets 的API。

官方网址:

http:///

添加评论·一回·2012-03-06 12:59

 uglify-js

uglify-js

Javascript 解析和压缩、格式化工具。

查看 CSSer 早期的翻译:

http://www./board/4f3f516e38a5ebc978000509

添加评论·一回·2012-03-06 12:57

 npm

npm

NPM 即 Node Package Manage,是 NodeJS 模块管理工具,当前已经内置于 NodeJS 中,所以不需要特意安装了。

NPM 官方网址:

http:///

添加评论·一回·2012-03-06 12:54

 mongoosejs

mongoosejs

Mongoose 是 MongoDB 数据库的模型工具,为 NodeJS 设计,工作于异步环境下。

查看 CSSer mongoose 标签更多内容

添加评论·一回·2012-03-06 12:51

 expressjs

expressjs

Express 是基于Node.js,高性能、一流的 web 开发框架。

Express JS 中文入门指引手册地址:

http://www./tools/express-js/express-guide-reference-zh-CN.html

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多