Node 登录模板 – Passport


Passport is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more.

基本上,passport已经提供整个项目结构,你真正需要的只是加入:'/login', passport.authenticate('local', { successRedirect: '/',
failureRedirect: '/login' }));

继续阅读: %s


之前我写了一点,简单的关于node的了解,关于event,关于modulize代码,这里想分享一个聊天室的范例讲解,来演示一下,怎么建立一个Node项目,client 和 server 如何沟通,和如何使用event,还有很有用的socketIO module。
Screen Shot 2013-12-19 at 5.13.54 pm
– 支持多人同时聊天
– 支持自定义名字
– 支持创建聊天室 继续阅读: %s

Using Node’s Event Module

EventEmitter: What and Why

节选自英文原文 ––net-35941

what exactly does the EventEmitter class do?

(EventEmitter class 的作用)
– Put simply, it allows you to listen for “events” and assign actions to run when those events occur.
These are very similar with mouse and keyboard events, except that we can emit events on our own, when we want to, and not necessary based on user interaction. The principles EventEmitter is based on have been called the publish/subscribe model, because we can subscribe to events and then publish them. There are many front-end libraries built with pub/sub support, but Node has it build in.
(简单来说,EventEmitter 监控各种“事件”,好像网页上的鼠标点击,键盘动作等等,然后根据事件驱动相关的”动作“,有了EventEmitter,我们能够构造自己的”事件“,按照”发行/接收“的方式,自由的创建自己的”事件“和”相关动作“) 继续阅读: %s

Organizing and Reusing Node functionality

(文章节选之 – Node in Action ©Manning Publications Co)
In some language implementations, such as PHP and Ruby, incorporating the logic from another file (we’ll call this the “included” file) can mean all the logic executed in the included file affects the global scope. This means that any variables created and functions declared in the included file risk overwriting those created and declared by the application. 继续阅读: %s

Node.JS Core explanation – 原理解释

继续阅读: %s

AngularJS App with an Node Express and mangoDB

推荐一篇文章 -> An Introduction To Full-Stack JavaScript
一般来说,full stack Javascript的构造如下:



  • 数据库 : mango
  • client side: Angular JS & jQuery & bootstrap 3
  • server side: NodeJS express framework
  • server : AWS free tier 继续阅读: %s

nodejs express framework 进阶

前面讲解了Node.js的最基础的建立服务器,和建立一个View的方式。下面我们来介绍,如何载入数据(load data)和如何动态的过滤数据(Filtering Data) 先在看看网页结构:

Screen Shot 2013-10-13 at 3.53.59 PM

这里用一个简单的MVC结构来演示这个例子 。 继续阅读: %s

NodeJS Express Framework 入门


    "name": "demo1",
    "description": "First Express app",
    "version": "0.0.1",
    "dependencies": {
        "express": "3.x"
npm install

继续阅读: %s

Node.JS Gathering User Input – readline

readline doc :

首先 createInterface:

var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout

其次 ask question:

interface.question('What is your favorite food?', function(answer) {
console.log('Oh, so your favorite food is ' + answer);

NodeJS Reading Arguments – optimist

继续阅读: %s