Part 1—Intro
1 What is Express?
2 The basics of Node.js
3 Foundations of Express

Part 1—Intro
1 What is Express?

Express.js เป็น framework ontop Node.js
Middleware and routing , เป็น 2 feature of Express
ต้องการRequest handler functions
นอกจาก Ruby , Python, C# , Java ใช้สำหรับ server แล้ว , js ก็เป็นอีกอันที่ควรเลือกสำหรับ server side applicaiton
V8 Javascript engine ->fast
– Node.js เป็น asynchronous
– หลีกเลี่ยง multithreads nightmare
Node.js สามารถ share code- browser and server
Express – คล้ายๆ jQuery , สามารถ add dynamic content
– แต่ตัว vanilla browser APIs – จะ verbose ,confusing และ limit feature
– เหมือน jQuery เพราะมัน extensible , ทำให้ extend ง่ายด้วย 3rd-party libraries


1.1 What is this Node.js business ?
ข้อดีของ Node.js คือเร็ว (แม้จะเร็วสุด)
– handle concurrency
ขณะที่ browser กำลังรอ responding แต่เกิดมี request จาก another
– มันจะบอก external database (แรก) และปล่อยให้คิดก่อน
– และมัน ก็สามารถ respond to 2nd request
– มันไม่ได้ทำงานสองอย่างพร้อมกัน แต่มันมี someone มาช่วยทำ
แต่ถ้าเป็น Ruby on Rails – จะสามารถ process ได้แค่ one request ต่อครั้ง , และถ้าต้องการทำงานมากกว่านี้ ต้องซื้อ more server

compare synchronus vs asynchronus
compare synchronus vs asynchronus

แต่จริงๆแล้ว ความเร็ว อาจจะไม่ปัจจัยที่ทำให้เราใช้ Node.js , แต่ข้อดี คือสามารถใช้ได้ทั้ง front-end and server โดย javascript

1.2 What is Express ?
ใช้ Node.js’s HTTP objects

p 6

2 The basics of Node.js

3 Foundations of Express