node. JS Getting Started

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.