1. Express JS
Web application framework for node
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
DESIGNVELOPER
2. What We need to start Express js?
• Knowledge
• Javascript basic
• Node js basic
• Using some component support for Express
• Backbone JS ( MVC Client )
• Template Engine Javascript: ejs, jade, mustache
• MongoDb, MySQL
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
3. How to setup Express JS?
• npm install (if var dependencies express version )
• npm install [-g] express ( lastest version )
• Express:
• -h, --help : Show help command
• -V, --version : Version of express
• -s, --sessions : Add support session for Express
• -e, --ejs : Use template engine is ejs (default: jade)
• -J, --jshtml : Use template engine is jshtml (default: jade)
• -H, --hogan: Use template engine is jshtml (default: jade)
• -c, --css: (less/stylus) (default: css)
If you want to generate an application with ejs and Stylus support you
would
Express –css stylus --ejs
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
4. Run Express JS Application?
• Use: node [project_main_js_file]
Ex: node app.js
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
5. Hello Express JS application
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
6. API Express JS
• APP
• REQUEST
• RESPONSE
• ROUTER
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
7. API Express JS
• Application
var express = require('express');
var app = express();
• App.set(name,value): Assigns setting name to value.
• App.get(name): Get setting name value.
• app.use([path], function): Use the given middleware
function, with optional mount path, defaulting to "/".
• Application Router
• app.VERB(path, [callback...], callback)
• VERB: Http verbs: GET, POST, PUT, DELETE
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
8. API Express JS
• REQUEST
• Req.params
• GET: /user/:name , req.params.name name
• Req.query
• GET: search?q=abc, req.query.q abc
• Req.param
• // ?name=abc, req.param('name') abc
• // POST name=abc, req.param('name') // “abc“
• /user/:name with req: //user/abc req.param('name')
// => “abc"
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
10. API Express JS
• ROUTER:
• var router = express.Router();
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
11. Building Application REST ful with Express Js
• Understand to start application nodejs with Express js
• Create module and require it
• Render view in express
• Router express
Developing more:
• Backbonejs
• MongoDb
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
12. Thanks you for watching!
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City
13. Attachment tools
Postman – REST Client:
https://chrome.google.com/webstore/detail/postman-rest-
client/fdmmgilgnpjigdojojpjoooidkmcomcm
Website: http://designveloper.com
Address: 250/6 Bau Cat, Ward 11, Tan Binh District, HCM City