First, preface
This weekend took some time to learn some of node. js. The main is to learn from the big direction. A preliminary understanding of some features, functionality, usage, and framework of node. js.
Second, the basis
Reference: http://www.runoob.com/nodejs/nodejs-tutorial.html
Third, MVC
node. JS MVC is mostly done with three templates, Express and Express-controller, and Ejs.
Express's Learning Address:
http://www.expressjs.com.cn/
Express-controller Study Address:
Https://www.npmjs.com/package/express-controller
Ejs Study Address:
http://www.embeddedjs.com/
An implementation of an MVC framework:
Https://gitee.com/junhandsome/express_mvc
Directory of the Framework:
Entry File Code:
//load a reference packagevarExpress =require ('Express');varExpresscontrollers = require ('Express-controller');varPath = require ('Path');varFavicon = require ('Serve-favicon');varLogger = require ('Morgan');varCookieparser = require ('Cookie-parser');varBodyparser = require ('Body-parser');varApp =Express ();varRouter =Express. Router ();//View LoadApp.Set(' views', Path.join (__dirname,' views') ); app.Set('View Engine','Ejs');//Static file LoadingApp.use (Express.Static(Path.join (__dirname,' Public')));//transfer data JSON processingApp.use (Logger ('Dev') ; App.use (Bodyparser.json ()); App.use (bodyparser.urlencoded ({extended:false}); App.use (Cookieparser () );//Routing ControlApp.use (router);//Binding Controllerexpresscontrollers. Setdirectory (__dirname+'/controllers'). bind (router);//Port StartApp.listen ( the)
Ejs Template File Usershow.ejs example (note the suffix name is. Ejs):
<!doctype html>"Zn">"UTF-8"> <title>Document</title> <link rel="stylesheet"href="/css/amazeui.min.css"> <script src="/js/jquery.min.js"></script>Database operations:
Http://www.runoob.com/nodejs/nodejs-mysql.html
Knowing this, you can basically start doing things with node. js.
node. JS Getting Started