CoffeeScriptNode系列——Node第三在模块使用总结

Node中主流模块汇总

1. 其他人总结的

  • https://github.com/sindresorhus/awesome-nodejs#videos

2. 数据库相关

  • express-session
    • 状态保持库
    • https://github.com/expressjs/session
  • connect-mongo
    • 将session存入mongodb
    • https://github.com/jdesboeufs/connect-mongo
  • connect-redis
    • 将session存入redis
    • https://github.com/tj/connect-redis orm mongoose

Drivers
    PostgreSQL - PostgreSQL client. Pure JavaScript and native libpq bindings.
    Redis - Redis client.
    LevelUP - LevelDB.
    MySQL - MySQL client.
    nano - CouchDB client.
    Aerospike - Aerospike client.
    Couchbase - Couchbase client.
    MongoDB - MongoDB driver.
ODM / ORM
    Sequelize - Multi-dialect ORM. Supports PostgreSQL, SQLite, MySQL.
    Bookshelf - ORM for PostgreSQL, MySQL and SQLite3 in the style of Backbone.js.
    Massive - PostgreSQL data access tool.
    Mongoose - Elegant MongoDB object modeling.
    Waterline - Datastore-agnostic tool that dramatically simplifies interaction with one or more databases.
    Iridium - MongoDB ORM with support for promises, distributed caching, preprocessing, validation and plugins.
    OpenRecord - ORM for PostgreSQL, MySQL, SQLite3 and RESTful datastores. Similar to ActiveRecord.
    orm2 - ORM for PostgreSQL, MariaDB, MySQL, Amazon Redshift, SQLite, MongoDB.
    firenze - Adapter-based ORM for MySQL, Memory, Redis, localStorage and more.
    pg-promise - PostgreSQL framework for native SQL using promises.
    Objection.js - Lightweight ORM built on the SQL query builder Knex.
Query builder
    Knex - Query builder for PostgreSQL, MySQL and SQLite3, designed to be flexible, portable, and fun to use.
Other
    NeDB - Embedded persistent database written in JavaScript.
    Lowdb - Small JavaScript database powered by Lodash.

3. 爬虫

  • cheerio
    • 网页爬虫处理,cheerio可以以服务端使用JQuery的类库,比如操作DOM元素
    • http://github.com/cheeriojs/cheerio

4. 全文检索

5. 日志

6. 发邮件

Nodemailer – The fastest way to handle email. emailjs – Send text/HTML
emails with attachments to any SMTP server.

7. 发短信

yunpian-sdk

8. 操作excel

npoi

  • xlsx-populate
    • 操作excel
    • https://github.com/dtjohnson/xlsx-populate

9. 测试

9.1. 单元测试

9.2. e2e测试

9.3. 压力测试

9.4. 数码模拟

AVA – Futuristic test runner. Mocha – Feature-rich test framework making
asynchronous testing simple and fun. nyc – Code coverage tool built on
istanbul that works with subprocesses. tap – TAP test framework. tape –
TAP-producing test harness. power-assert – Provides descriptive
assertion messages through the standard assert interface. Mochify – TDD
with Browserify, Mocha, PhantomJS and WebDriver. trevor – Run tests
against multiple versions of Node.js without switching versions manually
or pushing to Travis CI. loadtest – Run load tests for your web
application, with an API for automation. Sinon.JS – Test spies, stubs
and mocks. navit – PhantomJS / SlimerJS wrapper to simplify browser test
scripting. nock – HTTP mocking and expectations. intern – Code testing
stack. toxy – Hackable HTTP proxy to simulate failure scenarios and
network conditions. hook-std – Hook and modify stdout/stderr. testen –
Run tests for multiple versions of Node.js locally with NVM. Nightwatch

  • Automated UI testing framework based on Selenium WebDriver.
    WebdriverIO – Automated testing based on the WebDriver protocol. Jest –
    Painless JavaScript testing. TestCafe – Automated browser testing.

10. 事件队列

  • bee-queue
    • 包装了redis的事件队列 kue – Priority job queue backed by Redis.
      bull – Persistent job and message queue. agenda – Lightweight
      job scheduling on MongoDB. idoit – Redis-backed job queue engine
      with advanced job control.

11. 定时任务

node-schedule

12. 微信相关

  • wechaty

13. 表单

body-parse formable

14. 部署

PM2 – Advanced Process Manager. nodemon – Monitor for changes in your
app and automatically restart the server. node-mac – Run scripts as a
native Mac daemon and log to the console app. node-linux – Run scripts
as native system service and log to syslog. node-windows – Run scripts
as a native Windows service and log to the Event viewer. forever –
Ensures that a given script runs continuously. supervisor – Restart
scripts when they crash or restart when a *.js file changes. Phusion
Passenger – Friendly process manager that integrates directly into
Nginx. naught – Process manager with zero downtime deployment.

15. 人造智能

  • superscript

16. 工具类

glob uuid xml2json async(流程控制) axios fs-extra

  • moment
    • 日子拍卖
    • http://github.com/moment/moment
  • validator
    • 每当服务端和客户端都好开展说明的模块,常用的信箱,网址,电话,信用卡等还支持
    • https://github.com/chriso/validator.js
  • ccap
    • 生成图片验证码
    • https://cnodejs.org/topic/50f90d8edf9e9fcc58a5ee0b
    • https://cnodejs.org/topic/50fd3b74df9e9fcc58e776a0

17. 高级玩意

amqp bearcat(IoC,AOP)

18. 其他

  • gm
    • 图形处理
    • http://github.com/aheckmann/gm
    • 简介
      • ImageMagick和GraphicsMagick主要用以图片的创立、编辑、合成图。它们得以读取、转换、写副强格式的图纸。图片切割、颜色替换、各种力量的使用,图片的旋、组合,文本,直线,多边形,椭圆,曲线,附加到图片展开旋转。
      • gm模块实现了ImageMagick和GraphicsMagick的连带职能,让咱十分便宜之于Node中展开图片的相关操作
  • sharp
    • 重要用以图片的处理,相比ImageMagick 和 GraphicsMagick
      ,处理速度会快四五倍。主要支撑JPEG,PNG,WebP,TIFF,GIF 与 SVG
      images
    • http://github.com/lovell/sharp

18.1. spritesmith

  • 品类:图片处理
  • 官网:http://github.com/ensighten/spritesmith
  • 简介:
    • SSSprites在境内不少人数让css精灵,是平种网页图片以处理方式。它同意你用一个页面涉及到的装有零星图片都富含到均等摆放大图中失去,这样一来,当访问该页面时,载入的图形就未会见像以前那样一帧一轴地日益显示出了。
    • spritesmith 模块就是以多单图片生成 CSSSprites 和 拼成一摆放图
  • 代码:

var fs = require('fs');

var Spritesmith = require('spritesmith');

Spritesmith.run({
 src: [    __dirname + '/fork.png',    __dirname + '/github.png',    __dirname + '/twitter.png'
 ],
 engine: require('canvassmith')
}, function handleResult (err, result) {  
 if (err) {    throw err;
 }  
 fs.writeFileSync(__dirname + '/canvassmith.png', result.image);  result.coordinates, result.properties; });

18.2. TinyColor

  • 路:颜色处理
  • 官网:https://github.com/bgrins/TinyColor
  • 简介:
    • 当一般支出中,我们常会面处理局部颜色值的变换,正好TinyColor就派上用场了,能挺有益于之拓颜色值的易
  • 代码:

var color = tinycolor("red");

color.getFormat(); // "name"

color = tinycolor({r:255, g:255, b:255});

color.getFormat(); // "rgb"

18.3. pdfkit

  • 色:文档处理
  • 官网:http://github.com/devongovett/pdfkit
  • 简介:
    • 开局,生成PDF文件像是件非常烦的天职,但产生了PDFKit,这个职责就是易多矣。但对于Node.js的PDFKit模块,知道之丁并无多,这反是老奇怪。有了PDFKit模块,处理PDF文件变得非常容易,它让你避免了颇具的复杂性工作,并提供用CoffeeScript(也得以当作普通版的Javascript使用)写成的简易的API
  • 代码:

var PDF = require('pdfkit');      

var fs = require('fs'); 

var text = 'ANY_TEXT_YOU_WANT_TO_WRITE_IN_PDF_DOC'; 

doc = new PDF();             
doc.pipe(fs.createWriteStream('PATH_TO_PDF_FILE')); 

doc.text(text, 100, 100);        

doc.end();

18.4. marked

  • 品种:文件处理
  • 官网:http://github.com/chjj/marked
  • 简介:
    • Markdown
      是同种轻量级的「标记语言」,它的独到之处很多,目前为叫进一步多之创作爱好者,撰稿者广泛使用。因此显得Markdown格式的需求则随之而来,marked就会好好处理这个需求
  • 代码:

var marked = require('marked');

console.log(marked('I am using __markdown__.'));

// Outputs: <p>I am using <strong>markdown</strong>.</p>