SlideShare a Scribd company logo
WEB SERVICES
Why Node, Express and Postgres?
ABOUT ME.
• Programming as a hobby.
• Final student, NTU (Biz IT).
• Mainly involved in tech-related
entrepreneurial projects.
• Latest project is
VogueVerve.com.
CONTENTS.
• Nodejs
• Expressjs
• Node modules
– Passport
– Sequelize
– Bluebird
• Postgres, Mongo, Couchbase
IT’S SIMPLE.
IT’S JS FRONT-TO-BACK.
WHAT IS NODEJS?
• It is a server side Javascript
runtime environment.
• Powered by Chrome V8.
• Main intention of real-time
communication.
• It can be a standalone server.
WHO USES IT?
MAIN ATTRIBUTES.
• Single threaded.
• Async, non-blocking I/O.
• Event-oriented.
IT DOESN’T WAIT FOR
ANYTHING.
USING JS FOR SERVER-SIDE
APPLICATION SOUNDED LIKE
A BAD IDEA.
Search “Node.js is cancer”
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Auditorium
HOW TO NODE?
• Delegate computationally
intensive tasks to lower-level
languages like C++.
• Make clusters (to combat
single-threading).
• Node errors will crash the
server. Gotta catch ‘em all.
MODULAR CONCEPT.
NPM REPOSITORY.
• Modularity and versioning.
• Updates and releases.
• The best thing since beer.
WHAT IS EXPRESS?
EXPRESS.
• It is a Node Module.
• The most popular web
framework for Node.
• “Sinatra inspired”.
• Makes building web
application incredibly easy.
ROUTE HANDLING
`REQ` AND `RES`
OBJECTS.
• `req` comes for the user.
• `res` is sent back to the user.
• I use it extensively for “API-
styled” web platform.
REQ AND RES OBJECTS
API IN 3 SIMPLE STEPS
NODE MODULES
PASSPORTJS.
• Authentication API.
• Supports almost any kind of
authentication framework.
• FaceBook, Twitter, Google
OAuth modules already
available.
AN EXAMPLE
HOW TO USE IT?
• Documentation is abit skimpy
and untelling.
• Learn by example:
https://scotch.io/tutorials/easy-
node-authentication-setup-
and-local
SEQUELIZEJS.
• Object-Relational-Mapper
(ORM)
• Works with MySQL, Postgres
and others.
• Promise-styled. Very intuitive
and maintainable code.
• Support transactions.
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Auditorium
ACTIVE RECORDS
RAW QUERIES?
• You get replacements for free.
BLUEBIRD.
• Very good performance.
• Prevents `callback hell` in
asynchronous coding.
• Makes code very readable.
• Parallelism.
WHY ARE PROMISES SO
GOOD?
Because it’s very intuitive and
readable.
Codes that solves a problem but
cannot be easily understood, is a
problem.
CALLBACK HELL
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Auditorium
SOME ADVICES
• Don’t use modules that are not
well-maintained.
• Worry about performance, but
not too much.
POSTGRES, MONGO, COUCH.
Relational
data
Documents
?
Your data.Your storage.
vs
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Auditorium
MONGO AND COUCH -
JSON
Denormalized into a single
document. Fast.
IN THE MIDDLE
Use MongoDB/Couchbase + a
lot of indexing
OR
SQL with many many joins
SQL with serialized/encoded
arrays
THE OLD WAYS
• Joins are slow.
• Serializing can be problematic.
• Atomic updates impossible.
• Values cannot be used as
selection criteria.
MONGO AND COUCHBASE
CAN HANDLE SOME
“RELATIONAL” NEEDS AND
STILL REMAIN FAST. BUT…
THE PROBLEM
• What if Joe
changes
name?
• What if a
new field is
added to
users?
YOU MAY REACH A POINT
WHERE THERE IS JUST TOO
MUCH TO REPLICATE.
YOU CAN DO THIS AND IT IS
STILL PROBABLY FAST
You find yourself trying to do “joining”.
Are there any ORMs for
Mongo/Couchbase?
CHANGE IS THE ROOT OF ALL
PROBLEMS.
Will your data become more relational
than it is now?
http://www.sarahmei.com/blog/2013/11
/11/why-you-should-never-use-
mongodb/
POSTGRES JSON AND
HSTORE
• A field that can contain “array-
structured” data.
• Atomic operations: Key/values
can be searched for and
indexed.
• Fast.
• Best thing since NPM, and
beer.
A VERY FLEXIBLE
STRUCTURE
id name data
1 Mary { “country”: “Singapore”, “dataMeta”: { “following”: “299”, “followers”:
“484” }}
2 Lucy { “country”: “France”}
3 Jane null
4 Tom {“dataMeta”: { “following”: “479” }}
5 Dick {“dataMeta”: { “following”: “12”, followers: “40”}}
WHAT ABOUT THE NEED FOR
SPEED?
PERFORMANCE
• Different sources will stake
different claims.
• Comparing apples with
oranges.
• They are all quite fast.
TEST USING YOUR DATA
STRUCTURE AND YOUR
TYPICAL ROUTINE.
IT IS NOT PERFECT
• Only HSTORE supports atomic
updates, JSON does not.
• HSTORE does not support
nested structure.
• Postgres JSON is very new.
Library support is adequate
but not mature.
Relational
data
Documents
CONCLUSION ON PG
• It is a RDB that is very capable
of handling schemaless data.
• Don’t over-normalize your
data.
• Use relations and constraints
for critical portions of your
data.
1. SERVER-SIDE JAVASCRIPT
IS A GOOD IDEA.
2. IF YOU ARE BUILDING A
WEB SERVICE, USE EXPRESS.
3. ASK NOT WHAT A TECH
CAN DO FOR YOU. ASK WHAT
IT CANNOT DO.
KEEP IN TOUCH!
• Facebook: /calvintwr
• Email: calvin14@gmail.com

More Related Content

PDF
MongoTorino 2013 Opening Keynote
PDF
PHP Cloud Deployment Toolkits
PDF
Usersnap and the javascript magic behind the scenes - ViennaJS
PPTX
Untangling spring week11
PPTX
Untangling spring week10
PDF
Node.js primer
PDF
Introduction to the MEAN stack
PPTX
Untangling spring week9
MongoTorino 2013 Opening Keynote
PHP Cloud Deployment Toolkits
Usersnap and the javascript magic behind the scenes - ViennaJS
Untangling spring week11
Untangling spring week10
Node.js primer
Introduction to the MEAN stack
Untangling spring week9

What's hot (20)

PDF
Pagelet in action
PPTX
Untangling - fall2017 - week 8
PDF
What Multisite can do for You - Anthony Cole - WordCamp Sydney 2012
PDF
Use all the buzzwords
PDF
Migrating Edmunds.com to AWS (re:Invent 2013 DMG205)
PPTX
Untangling spring week8
PPTX
Introduction to NodeJS
PPT
Beyond the MEAN Stack: Thinking Small with Node.js for the Enterprise
PDF
Vagrant + Veewee : Barcampboston April 10-2011
PPT
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
PDF
MongoBoston - MongoHQ
PDF
Fi fo euc 2014
PPTX
Part One: Building Web Apps with the MERN Stack
PPTX
Angular js introduction
PDF
Webpack: What it is, What it does, Whether you need it
PPT
Extreme Javascript Minification
PDF
Hello npm
PDF
Building ZingMe News Feed System
PDF
The Bleeding Edge
PDF
Dangerous CSS
Pagelet in action
Untangling - fall2017 - week 8
What Multisite can do for You - Anthony Cole - WordCamp Sydney 2012
Use all the buzzwords
Migrating Edmunds.com to AWS (re:Invent 2013 DMG205)
Untangling spring week8
Introduction to NodeJS
Beyond the MEAN Stack: Thinking Small with Node.js for the Enterprise
Vagrant + Veewee : Barcampboston April 10-2011
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
MongoBoston - MongoHQ
Fi fo euc 2014
Part One: Building Web Apps with the MERN Stack
Angular js introduction
Webpack: What it is, What it does, Whether you need it
Extreme Javascript Minification
Hello npm
Building ZingMe News Feed System
The Bleeding Edge
Dangerous CSS
Ad

Viewers also liked (17)

PDF
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
PDF
Node.js in action
PDF
Node.js & Twitter Bootstrap Crash Course
PDF
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
PPTX
Java script at backend nodejs
PPTX
Intro To Node.js
PDF
Introduction to node js - From "hello world" to deploying on azure
PDF
All aboard the NodeJS Express
PDF
Complete MVC on NodeJS
PPT
Nodejs Event Driven Concurrency for Web Applications
PPTX
Create Rest API in Nodejs
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
PDF
Debugging node in prod
PDF
NodeJS for Beginner
PDF
Node, express & sails
PDF
Express node js
PDF
Node.js and The Internet of Things
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
Node.js in action
Node.js & Twitter Bootstrap Crash Course
Burgas Conf 21.06.2014 - Single page application Angularjs and Nodejs
Java script at backend nodejs
Intro To Node.js
Introduction to node js - From "hello world" to deploying on azure
All aboard the NodeJS Express
Complete MVC on NodeJS
Nodejs Event Driven Concurrency for Web Applications
Create Rest API in Nodejs
Workshop 4: NodeJS. Express Framework & MongoDB.
Debugging node in prod
NodeJS for Beginner
Node, express & sails
Express node js
Node.js and The Internet of Things
Ad

Similar to Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Auditorium (20)

PPTX
Dapper: the microORM that will change your life
PPTX
Untangling spring week1
PPTX
Untangling the web week1
PDF
Why we love ArangoDB. The hunt for the right NosQL Database
PDF
From a student to an apache committer practice of apache io tdb
PPTX
Untangling fall2017 week1
PDF
Node.js
PDF
An introduction to Node.js
PDF
Big Data! Great! Now What? #SymfonyCon 2014
PDF
Developing and Testing a MongoDB and Node.js REST API
PDF
TDD a REST API With Node.js and MongoDB
PPTX
Scalable server component using NodeJS & ExpressJS
PDF
Stackato v2
PPTX
MongoDB: How We Did It – Reanimating Identity at AOL
PPTX
NoSQL and MongoDB Introdction
PPTX
Be faster then rabbits
PDF
Stackato v3
PDF
Django è pronto per l'Enterprise
PDF
Stackato v5
PDF
AMW43 - Unba.se, Distributed database for human interaction
Dapper: the microORM that will change your life
Untangling spring week1
Untangling the web week1
Why we love ArangoDB. The hunt for the right NosQL Database
From a student to an apache committer practice of apache io tdb
Untangling fall2017 week1
Node.js
An introduction to Node.js
Big Data! Great! Now What? #SymfonyCon 2014
Developing and Testing a MongoDB and Node.js REST API
TDD a REST API With Node.js and MongoDB
Scalable server component using NodeJS & ExpressJS
Stackato v2
MongoDB: How We Did It – Reanimating Identity at AOL
NoSQL and MongoDB Introdction
Be faster then rabbits
Stackato v3
Django è pronto per l'Enterprise
Stackato v5
AMW43 - Unba.se, Distributed database for human interaction

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
1. Introduction to Computer Programming.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
MIND Revenue Release Quarter 2 2025 Press Release
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Assigned Numbers - 2025 - Bluetooth® Document
Building Integrated photovoltaic BIPV_UPV.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
“AI and Expert System Decision Support & Business Intelligence Systems”
1. Introduction to Computer Programming.pptx
NewMind AI Weekly Chronicles - August'25-Week II

Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Auditorium