Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Build Your Application On Node.js
Search
mahdi pedramrazi
March 21, 2014
Programming
1
130
Build Your Application On Node.js
mahdi pedramrazi
March 21, 2014
Tweet
Share
More Decks by mahdi pedramrazi
See All by mahdi pedramrazi
CSS Shapes
pedramphp
1
66
Node.js Application Architecture.
pedramphp
0
870
CSS Best Practices
pedramphp
0
130
How to write UI Components
pedramphp
0
96
Other Decks in Programming
See All in Programming
組織で育むオブザーバビリティ
ryota_hnk
0
170
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
100
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
120
AI時代の認知負荷との向き合い方
optfit
0
160
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
560
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
960
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
We Are The Robots
honzajavorek
0
160
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
Discover your Explorer Soul
emna__ayadi
2
1.1k
How STYLIGHT went responsive
nonsquared
100
6k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
120
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
37k
Transcript
Build Your Applica.on On Node.js Mahdi Pedramrazi
Agenda • What is Node.js • Hello world
with Node.js • Node modules • Callback Hell vs Modular Code • Promises
What is Node.js • PlaDorm built on Chrome's JavaScript
run.me (V8 JavaScript engine) • Building fast, scalable Internet applica.ons. • Event-‐driven, non-‐blocking I/O model • Lightweight and efficient • 8000 lines of C/C++, 2000 lines of Javascript • 14 contributors. ( 2009 )
Event Loop • Single threaded • Doesn’t spend
.me wai.ng for things to finish • Sequen.ally execute a number of tasks very rapidly
Hello World • Download Node.js from h`p://nodejs.org •
Install Node.js • Open your Terminal • Type “node” • Type “console.log(‘Hello World’);
Hello World on Your Server Open Terminal and Type:
node helloworld.js
How to Load Modules. // Node Built In modules
var h`p = require('h`p'); //custom modules var customModule = require('path/to/your/module');
Node Modules h`p://nodejs.org/api/ 35+ Build In Modules
require(“h`p”); require(“path”); require(“process”); require(“os”);
How to load dependencies Package.json cheatsheet
How to load Public Modules NPM ( Node Packaged
Modules ) npmjs.org In the root folder run: “npm install” loads all dependencies from package.json //updates package.json Npm install –save moment
Asynchronous Model quiz var ac.on_one = RPS.getEvents(func.on(){ console.log(arguments);
}); var ac.on_two = RPS.getEvent(“test”, func.on(){ console.log(arguments); }); var Ac.on_three = require('events').EventEmi`er;
Callback Hell
Name Your Func.on
Reduce Nes.ng
None
Modularize!
Issac Schlueter (NPM Developer ) Write small modules that
each do one thing, and assemble them into other modules that do a bigger thing. You can't get into callback hell if you don't go there.
CommonJS • Modern JavaScript Design pa`ern. • CommonJS
module is a reusable piece of JavaScript which exports specific objects made available to any dependent code. • Unlike AMD, there are typically no func.on wrappers around such modules (so we won't see define here for example).
CommonJS to the rescue Formuploader.js
Callback hell vs Modular code
Paradigm of Doom the situa.on where code marches to
the right faster than it marches forward.
Callback Limita.ons Dependency Management can become messy
Error Handling is a Nightmare
Promises Represents a proxy for a value which
is not known at it’s crea.on .me.
Promise Fulfilled The ac.on rela.ng to the promise
succeeded
Promise Rejected The ac.on rela.ng to the promise
Failed
Promise Pending Hasn’t fulfilled or rejected yet
Promise se`led Has Fulfilled or rejected
Promise Libraries • Q • When
• RQ ( Doug Crockford ) • Deffered • Async
Q – Promise
Se`led • Use allSe`led If you want to wait
for all of the promises to either be fulfilled or rejected.
Q -‐ Error Handling
Q -‐ Progress no.fica.on
How to Create a Promise Func.on
None
Q – Promise Example
Useful Links Express -‐ Web development framework for
Node.js Tips, Libraries, Tutorials Q.Js Node Inspector