13
Working With NodeJS By Vu Tran September 4, 2016

Working with NodeJS

  • Upload
    vu-tran

  • View
    206

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Working with NodeJS

Working With NodeJSBy Vu Tran

September 4, 2016

Page 2: Working with NodeJS

A Brief Introduction of Myself

• Self-taught since H.S.

• Past and Current Involvement:

• Worked with many high profile clients

• Consulting and startups

• Open-source

vutran @tranvu

Page 3: Working with NodeJS

What Is Node?

• Non-blocking event-driven JavaScript runtime

• Built on V8 (same engine used by Chrome)

What Isn’t Node?

• Language (JavaScript, Ruby, Python, etc.)

• Framework (Rails, Phoenix, Laravel)

• Server (Apache, Nginx, etc.)

Page 4: Working with NodeJS

Simple Web Server

Page 5: Working with NodeJS

Blocking I/O

• Synchronous executions

• Easier to read

• If you like standing in line at Starbucks

Page 6: Working with NodeJS

Non-Blocking I/O

• Asynchronous executions

• Higher concurrency

Page 7: Working with NodeJS

Pseudo Starbucks App

Page 8: Working with NodeJS

File System (fs)

• Access to the file system

• Async/Sync Methods

• Streams

Page 9: Working with NodeJS

Streams

• Great for handling big data

• pipe() chunks of data

Page 10: Working with NodeJS

Reading Large Files (fs + stream + readline)

Page 11: Working with NodeJS

Parsing Raw Data

Page 12: Working with NodeJS

Parsing Raw Data

Page 13: Working with NodeJS

Don’t Repeat Yourself!

• Too much code to remember

• Duplicate code through the entire project

• There’s a module for that!

• Write a new module if there isn’t one

• Publish your modules on npm/github

• Private modules