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
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
670
Data-Centric Kaggle
isax1015
2
770
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
180
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
620
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
190
CSC307 Lecture 03
javiergs
PRO
1
490
2026年 エンジニアリング自己学習法
yumechi
0
130
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
280
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
BBQ
matthewcrist
89
10k
Fireside Chat
paigeccino
41
3.8k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
57
50k
Paper Plane
katiecoart
PRO
0
46k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
170
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
Docker and Python
trallard
47
3.7k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
170
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
110
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