Monthly Archives: November 2016

how is the call back parameter defined?

http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them 调用那个callback的函数,其函数体内应标明这个callback的参数是怎么赋值的,即其中应该明确哪些参数及如何赋值给此callback callback的内部逻辑可以用户自己定义 可以pass更多的参数给callback,但在callback逻辑内部要表明如何使用它 prototype只是给这一类obj提供base property或method when passing a function as parameter, we only pass the function definition callback is closure When we pass a callback function as an argument to another function, the callback is executed at some point … Continue reading

Posted in Nodejs | Leave a comment

nodejs error handling

https://www.joyent.com/node-js/production/design/errors error vs. exception An error is any instance of the Error class. Errors may be constructed and then passed directly to another function or thrown. When you throw an error, it becomes an exception.2Here’s an example of using an … Continue reading

Posted in Nodejs | Leave a comment

nodejs authentication & authorization

passport session based authentication, not good for rest jwt (json web token) to create a token for use also able to recognize it base on the username/password when create token? algorithm & key? base on date time also? iat?

Posted in Nodejs | Leave a comment

nodejs todo

logging with mongodb authentication authorization

Posted in Todo | Leave a comment

nodejs logging

https://blog.risingstack.com/node-js-logging-tutorial/ winston logging to mongodb need correlation id

Posted in Nodejs | Leave a comment

package.json

create package.json npm init to create the package.json file and then you use ls node_modules/ |xargs npm install –save update package.json with the new package npm install <pkg> –save //or npm install <pkg> –save-dev uninstall a package npm uninstall <pkg> … Continue reading

Posted in Nodejs | Leave a comment

process.env

process global obj that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require(). process.env property returns an object containing the user environment. It is possible to modify … Continue reading

Posted in Nodejs | Leave a comment

express middleware

best slide http://www.slideshare.net/yashprit1/express-node-js-35689155?next_slideshow=2 http://evanhahn.com/understanding-express/ request handler build on connect middleware extensible HTTP server framework for node, providing high performance “plugins” known as middleware. More specifically, connect wraps the Server, ServerRequest, and ServerResponse objects of node.js’ standard httpmodule, giving them a … Continue reading

Posted in Nodejs | Leave a comment

nodejs variable

req req.param req.query req.body req.session req.flash req.headers res res.redirect res.write res.end ??? res.download ???

Posted in Nodejs | Leave a comment

nodejs express

a web app framework just like java ee? grails? functionality configuration routing view, template session security middleware (controller?) request handler routing, controller, model, view… more than just controller next() trigger the next call back use function add middleware build on … Continue reading

Posted in Nodejs | Leave a comment