SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
Jakarta JS
Back to Basic of Node.js and Reactivity
RESTful API with Node.js + MongoDB
About Me
• Name : Sofian Hadiwijaya
• Email : me@sofianhw.com
• Blog : http://www.sofianhw.com
• Id : sofianhw
Basic - RESTful
Wikipedia, that infallible source, defines
Representational State Transfer (REST) as: an
architectural style that abstracts the architectural
elements within a distributed hypermedia system.
Basic - RESTful
Four basic design principles from IBM's developerWorks website
1.Use HTTP methods explicitly
2.Be Stateless
3.Expose directory structure-like URIs
4.Transfer XML or JSON, or Both
Basic - Express JS
A minimal and flexible node.js web application framework, providing a
robust set of features for building full web applications and/or APIs.
$ npm install express
• Middleware
• Routing
Basic - Express
Express Hello World
Basic - Express
A router object is an isolated instance of middleware and routes,
capable only of performing middleware and routing functions.
A router behaves like middleware itself, so you can use it as an
argument to app.use() or as the argument to another router’s use()
method.
Every Express application has a built-in app router:
Basic - Express
Chainable route handlers for a route path can be created using app.route().

Since the path is specified at a single location, it helps to create modular
routes and reduce redundancy and typos.
Basic - Mongoose
elegant mongodb object modeling for node.js
$ npm install mongoose
Build Basic RESTful
Very simple file structure
Defining Node Packages
Build Basic RESTful
Clone repository
$ git clone https://github.com/sofianhw/simple-restful-nodejs.git
Install packages with
$ npm install
Running Script
$ npm start
Model
Routes
Basic Testing - Mocha
Mocha is a simple, flexible, fun JavaScript test framework for node.js and
the browser.
$ npm install -g mocha
Basic Testing - Should
should is an expressive, readable, framework-agnostic assertion library. The
main goals of this library are to be expressive and to be helpful. It keeps your test
code clean, and your error messages helpful.
$ npm install should
Basic Testing - Supertest
HTTP assertions made easy via super-agent
$ npm install supertest

Contenu connexe

Tendances

Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappers
Manolis Vavalis
 

Tendances (20)

Mule quartz
Mule quartz Mule quartz
Mule quartz
 
Advance java session 20
Advance java session 20Advance java session 20
Advance java session 20
 
Mule: Java Transformer
Mule: Java TransformerMule: Java Transformer
Mule: Java Transformer
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Shipping your logs to elk from mule app/cloudhub part 3
Shipping  your logs to elk from mule app/cloudhub  part 3Shipping  your logs to elk from mule app/cloudhub  part 3
Shipping your logs to elk from mule app/cloudhub part 3
 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
 
Introduction To Mule
Introduction To MuleIntroduction To Mule
Introduction To Mule
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappers
 
Consume wsa
Consume wsaConsume wsa
Consume wsa
 
Mule technologies
Mule technologiesMule technologies
Mule technologies
 
XMPP Academy #2
XMPP Academy #2XMPP Academy #2
XMPP Academy #2
 
2 Basics
2 Basics2 Basics
2 Basics
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
Enabling Security For ActiveMQ JMX Access
Enabling Security For ActiveMQ JMX AccessEnabling Security For ActiveMQ JMX Access
Enabling Security For ActiveMQ JMX Access
 
Test
TestTest
Test
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
 
Mule: Java Component
Mule: Java ComponentMule: Java Component
Mule: Java Component
 
Mule properties
Mule propertiesMule properties
Mule properties
 
Mule concepts transformers
Mule concepts transformersMule concepts transformers
Mule concepts transformers
 
MuleSoft ESB Scripting Example
MuleSoft ESB Scripting ExampleMuleSoft ESB Scripting Example
MuleSoft ESB Scripting Example
 

En vedette

En vedette (12)

Web Analytics
Web Analytics Web Analytics
Web Analytics
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Realtime traffic monitoring
Realtime traffic monitoringRealtime traffic monitoring
Realtime traffic monitoring
 
Developing Virtual Reality Content
Developing Virtual Reality ContentDeveloping Virtual Reality Content
Developing Virtual Reality Content
 
IoT Presentation - Unsri - Palembang
IoT Presentation - Unsri - PalembangIoT Presentation - Unsri - Palembang
IoT Presentation - Unsri - Palembang
 
ES 6 - Jakarta Javascript Meetup
ES 6 - Jakarta Javascript MeetupES 6 - Jakarta Javascript Meetup
ES 6 - Jakarta Javascript Meetup
 
Docker 101 for Developer
Docker 101 for DeveloperDocker 101 for Developer
Docker 101 for Developer
 
IoT Platform with MQTT and Websocket
IoT Platform with MQTT and WebsocketIoT Platform with MQTT and Websocket
IoT Platform with MQTT and Websocket
 
Pre-Hackathon FinTech - DBS
Pre-Hackathon FinTech - DBSPre-Hackathon FinTech - DBS
Pre-Hackathon FinTech - DBS
 
Machine Learning and Internet of Things
Machine Learning and Internet of ThingsMachine Learning and Internet of Things
Machine Learning and Internet of Things
 
Minimum viable product
Minimum viable productMinimum viable product
Minimum viable product
 
Intro to Big Data - Spark
Intro to Big Data - SparkIntro to Big Data - Spark
Intro to Big Data - Spark
 

Similaire à Javascript Basic RESTful

Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
Rob Davarnia
 

Similaire à Javascript Basic RESTful (20)

ExpressJS-Introduction.pdf
ExpressJS-Introduction.pdfExpressJS-Introduction.pdf
ExpressJS-Introduction.pdf
 
Expo Router V2
Expo Router V2Expo Router V2
Expo Router V2
 
Node JS | Dilkash Shaikh Mahajan
Node JS | Dilkash Shaikh MahajanNode JS | Dilkash Shaikh Mahajan
Node JS | Dilkash Shaikh Mahajan
 
Building Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJs
 
ExpressJS and REST API.pptx
ExpressJS and REST API.pptxExpressJS and REST API.pptx
ExpressJS and REST API.pptx
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Mean PPT
Mean PPTMean PPT
Mean PPT
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
 
Meanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore ChandraMeanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore Chandra
 
Best node js course
Best node js courseBest node js course
Best node js course
 
Meanstack overview
Meanstack overviewMeanstack overview
Meanstack overview
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 

Plus de Sofian Hadiwijaya

Plus de Sofian Hadiwijaya (20)

Workshop Web3 Weekend Social Impact
Workshop Web3 Weekend Social ImpactWorkshop Web3 Weekend Social Impact
Workshop Web3 Weekend Social Impact
 
Warung Pintar Social Impact Report 2018
Warung Pintar Social Impact Report 2018Warung Pintar Social Impact Report 2018
Warung Pintar Social Impact Report 2018
 
Agile and Scrum 101
Agile and Scrum 101Agile and Scrum 101
Agile and Scrum 101
 
Execute Idea
Execute Idea Execute Idea
Execute Idea
 
Product market fit and Scale
Product market fit and ScaleProduct market fit and Scale
Product market fit and Scale
 
Entrepreneur Story
Entrepreneur StoryEntrepreneur Story
Entrepreneur Story
 
Pathway became data scientist
Pathway became data scientistPathway became data scientist
Pathway became data scientist
 
Keynote Speaker PyConID 2018
Keynote Speaker PyConID 2018Keynote Speaker PyConID 2018
Keynote Speaker PyConID 2018
 
Building Startups
Building StartupsBuilding Startups
Building Startups
 
Big data and digital marketing
Big data  and digital marketingBig data  and digital marketing
Big data and digital marketing
 
Data Driven Organization
Data Driven OrganizationData Driven Organization
Data Driven Organization
 
Data Driven Company
Data Driven CompanyData Driven Company
Data Driven Company
 
serverless web application
serverless web applicationserverless web application
serverless web application
 
Startup 101
Startup 101Startup 101
Startup 101
 
IoT and AI for Retail Industry
IoT and AI for Retail IndustryIoT and AI for Retail Industry
IoT and AI for Retail Industry
 
Growth in Startup
Growth in StartupGrowth in Startup
Growth in Startup
 
Technology Industry
Technology Industry Technology Industry
Technology Industry
 
What you can get with data
What you can get with dataWhat you can get with data
What you can get with data
 
DeepLearning with Neon
DeepLearning with NeonDeepLearning with Neon
DeepLearning with Neon
 
How BigData Affects Business
How BigData Affects BusinessHow BigData Affects Business
How BigData Affects Business
 

Dernier

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Javascript Basic RESTful

  • 1. Jakarta JS Back to Basic of Node.js and Reactivity RESTful API with Node.js + MongoDB
  • 2. About Me • Name : Sofian Hadiwijaya • Email : me@sofianhw.com • Blog : http://www.sofianhw.com • Id : sofianhw
  • 3. Basic - RESTful Wikipedia, that infallible source, defines Representational State Transfer (REST) as: an architectural style that abstracts the architectural elements within a distributed hypermedia system.
  • 4. Basic - RESTful Four basic design principles from IBM's developerWorks website 1.Use HTTP methods explicitly 2.Be Stateless 3.Expose directory structure-like URIs 4.Transfer XML or JSON, or Both
  • 5. Basic - Express JS A minimal and flexible node.js web application framework, providing a robust set of features for building full web applications and/or APIs. $ npm install express • Middleware • Routing
  • 7. Basic - Express A router object is an isolated instance of middleware and routes, capable only of performing middleware and routing functions. A router behaves like middleware itself, so you can use it as an argument to app.use() or as the argument to another router’s use() method. Every Express application has a built-in app router:
  • 8. Basic - Express Chainable route handlers for a route path can be created using app.route().
 Since the path is specified at a single location, it helps to create modular routes and reduce redundancy and typos.
  • 9. Basic - Mongoose elegant mongodb object modeling for node.js $ npm install mongoose
  • 10. Build Basic RESTful Very simple file structure Defining Node Packages
  • 11. Build Basic RESTful Clone repository $ git clone https://github.com/sofianhw/simple-restful-nodejs.git Install packages with $ npm install Running Script $ npm start
  • 12. Model
  • 14. Basic Testing - Mocha Mocha is a simple, flexible, fun JavaScript test framework for node.js and the browser. $ npm install -g mocha
  • 15. Basic Testing - Should should is an expressive, readable, framework-agnostic assertion library. The main goals of this library are to be expressive and to be helpful. It keeps your test code clean, and your error messages helpful. $ npm install should
  • 16. Basic Testing - Supertest HTTP assertions made easy via super-agent $ npm install supertest