node.js lab

39
LeoNguyen.com

Upload: leo-nguyen

Post on 01-Sep-2014

1.278 views

Category:

Entertainment & Humor


3 download

DESCRIPTION

Node.js Lab http://leonguyen.com

TRANSCRIPT

Page 2: Node.js Lab

Outline

- Node.js References (leonguyen.com/nodejs/references.html)- Express.js References (leonguyen.com/nodejs/expressjs/references/)- Node.js Sites (leonguyen.com/nodejs/Sites.html)- Lab 01: Node.js- Lab 02: Express.js

Page 3: Node.js Lab

Lab 01

Node.js

Page 4: Node.js Lab

Outline

- Lab 01: Introduction to Node.js

Page 5: Node.js Lab

Outline

- Install Node.js on Windows- Install Node.js on Linux- Write a Hello Console- Write a Hello HTTP- Write a Hello TCP- Write a Hello UDP

Page 6: Node.js Lab

Overview

Page 7: Node.js Lab

Overview (cont)

Page 8: Node.js Lab

Overview (cont)

Page 9: Node.js Lab

Overview (cont)

Page 10: Node.js Lab

Exercise 1

Install Node.js

Page 11: Node.js Lab

Task 1 - On Windows

- Goto Node.js download site nodejs.org/download (See: youtu.be/n9cs8Bmb6KU)- Check version: using command node -v (See: youtu.be/-hZ9-qkxxOc)

Page 12: Node.js Lab

Task 1 - On Linux

- Install on Ubuntu (See: youtu.be/8widdkdSo58)- Install on CentOS (See: youtu.be/bPObquO4FCM)- Check version: using command node -v (See: youtu.be/-hZ9-qkxxOc)

Page 13: Node.js Lab

Exercise 2

Write a Hello Console

Page 14: Node.js Lab

Task 1 - Write a hello-console.js

- Enter code: https://gist.github.com/leonguyen/6472852

Page 15: Node.js Lab

Task 2 - Run

- Using command: node hello-console.js (See: youtu.be/LxGlcdR53To)

Page 16: Node.js Lab

Exercise 3

Write a Hello HTTP

Page 17: Node.js Lab

Task 1 - Write a hello-http.js

- Enter code: https://gist.github.com/leonguyen/6492146

Page 18: Node.js Lab

Task 2 - Run

- Using command: node hello-http.js (See: youtu.be/IpafeSP6_dg)

Page 20: Node.js Lab

Exercise 4

Write a Hello TCP

Page 21: Node.js Lab

Task 1 - Write a hello-tcp.js

- Enter code: https://gist.github.com/leonguyen/6492200

Page 22: Node.js Lab

Task 2 - Run

- Using command: node hello-tcp.js (See: youtu.be/5_dVVRmcjWg)

Page 23: Node.js Lab

Exercise 5

Write a Hello UDP

Page 24: Node.js Lab

Task 1 - Write a hello-udp.js

- Enter code: https://gist.github.com/leonguyen/6492554

Page 25: Node.js Lab

Task 2 - Write a client-hello-udp.js

- Enter code: https://gist.github.com/leonguyen/6492588

Page 26: Node.js Lab

Task 3 - Run UDP

- Using command: node hello-udp.js (See: youtu.be/3SzAxXu2zDI)

Page 27: Node.js Lab

Task 4 - Run UDP Client

- Using command: node client-hello-udp.js (See: youtu.be/syyp0TWQd4U)

Page 28: Node.js Lab

Lab 02

Express.js

Page 29: Node.js Lab

Outline

- Install and config Express.js- Generate an application- MySQL

Page 30: Node.js Lab

Exercise 1

Install and config Express.js

Page 31: Node.js Lab

Task 1 - Create package.json

- Check NPM: using command npm -v (See: youtu.be/_x3EzBCBd_o)- Enter code: https://gist.github.com/leonguyen/6504935

Page 32: Node.js Lab

Task 2 - Install Express.js

- Install Express: using command npm install (See: youtu.be/umjcT1sH22Q) or npm install -g express (for available from anywhere)- Check Express: using command express --version (See: youtu.be/a8H41rePUJM)

Page 33: Node.js Lab

Exercise 2

Generate an application

Page 34: Node.js Lab

Task 1 - Generate an application

- Using command express --sessions --css stylus --ejs [nodeapp] (See: youtu.be/7QMhdISI-7s)

Page 35: Node.js Lab

Task 2 - Install dependencies

- Using command npm install (See: youtu.be/qgi16SrXcTI)

Page 36: Node.js Lab

Task 3 - Run

- Using command node app (See: youtu.be/xFBKkD4xC5w)

Page 38: Node.js Lab

Exercise 3

MySQL

Page 39: Node.js Lab

Task 1 - Install MySQL

- Using command npm install mysqlSee: youtu.be/uEWKuQQiPVs, youtu.be/CB80P8_i7gg (CentOS)