Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node.js Lab

Node.js Lab

Node.js Lab
http://leonguyen.com

LeoNguyen.com

March 28, 2014
Tweet

More Decks by LeoNguyen.com

Other Decks in Programming

Transcript

  1. LeoNguyen.com

    View full-size slide

  2. 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

    View full-size slide

  3. Lab 01
    Node.js

    View full-size slide

  4. Outline
    - Lab 01: Introduction to Node.js

    View full-size slide

  5. 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

    View full-size slide

  6. Overview (cont)

    View full-size slide

  7. Overview (cont)

    View full-size slide

  8. Overview (cont)

    View full-size slide

  9. Exercise 1
    Install Node.js

    View full-size slide

  10. 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)

    View full-size slide

  11. 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)

    View full-size slide

  12. Exercise 2
    Write a Hello Console

    View full-size slide

  13. Task 1 - Write a hello-console.js
    - Enter code: https://gist.github.com/leonguyen/6472852

    View full-size slide

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

    View full-size slide

  15. Exercise 3
    Write a Hello HTTP

    View full-size slide

  16. Task 1 - Write a hello-http.js
    - Enter code: https://gist.github.com/leonguyen/6492146

    View full-size slide

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

    View full-size slide

  18. Task 3 - Run
    - Go to: http://localhost:8000/

    View full-size slide

  19. Exercise 4
    Write a Hello TCP

    View full-size slide

  20. Task 1 - Write a hello-tcp.js
    - Enter code: https://gist.github.com/leonguyen/6492200

    View full-size slide

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

    View full-size slide

  22. Exercise 5
    Write a Hello UDP

    View full-size slide

  23. Task 1 - Write a hello-udp.js
    - Enter code: https://gist.github.com/leonguyen/6492554

    View full-size slide

  24. Task 2 - Write a client-hello-udp.js
    - Enter code: https://gist.github.com/leonguyen/6492588

    View full-size slide

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

    View full-size slide

  26. Task 4 - Run UDP Client
    - Using command: node client-hello-udp.js (See: youtu.
    be/syyp0TWQd4U)

    View full-size slide

  27. Lab 02
    Express.js

    View full-size slide

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

    View full-size slide

  29. Exercise 1
    Install and config Express.js

    View full-size slide

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

    View full-size slide

  31. 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)

    View full-size slide

  32. Exercise 2
    Generate an application

    View full-size slide

  33. Task 1 - Generate an application
    - Using command express --sessions --css stylus --ejs [nodeapp] (See:
    youtu.be/7QMhdISI-7s)

    View full-size slide

  34. Task 2 - Install dependencies
    - Using command npm install (See: youtu.be/qgi16SrXcTI)

    View full-size slide

  35. Task 3 - Run
    - Using command node app (See: youtu.be/xFBKkD4xC5w)

    View full-size slide

  36. Task 4 - Run
    - Go to: http://localhost:3000 and http://localhost:3000/users

    View full-size slide

  37. Exercise 3
    MySQL

    View full-size slide

  38. Task 1 - Install MySQL
    - Using command npm install mysql
    See: youtu.be/uEWKuQQiPVs, youtu.be/CB80P8_i7gg (CentOS)

    View full-size slide