SlideShare a Scribd company logo
1 of 10
Building an API backend with
LoopBack in 5 Minutes

Raymond Feng
Co-Founder and Architect
StrongLoop, Inc.
Why do I need an API
backend?
• Build mobile applications that need to
produce/consume data
– Account for gamers.

• Provision a backend that provides APIs/SDKs
– REST, JS, iOS, Android

• Pick a database
– MongoDB, MySQL, Oracle, PostgreSQL, …
– CRUD and beyond, queries and relations, …
Let’s scaffold a Node.js API
server
1.
2.
3.
4.
5.

npm install -g strong-cli (only once)
slc lb project loopback-mysql-example
cd loopback-mysql-example
slc lb datasource mysql --connector mysql
slc lb model account -i --data-source mysql
–
–
–
–

email: string - The email id for the account
level: number - The game level you are in
created: date - The date your account is created
modified: date - The date your account is updated

6. npm install loopback-connector-mysql --save
Connect to MySQL
• Update datasources.json
"mysql": {
"connector": "mysql",
"host": "myserver",
"port": 3306,
"database": "demo",
"username": "demo",
"password": "password"
}
Ready to go!
• Start the server
– node app
– http://localhost:3000/explorer

• Create table in MySQL and add test data
– node create-test-data.js
– http://localhost:3000/api/accounts
– http://localhost:3000/api/accounts/1

• Discover models from MySQL tables
– node discover.js
Show me the code
• https://github.com/strongloopcommunity/loopback-mysql-example
Switch to MongoDB
• datasources.json
"mongodb": {
"connector": "mongodb",
"host": "server",
"port": 27017,
"database": "demo",
"username": "demo",
"password": "password"
}

• models.json
– Change the dataSource property for Account model to
be “mongodb”
What’s the magic? LoopBack!
LoopBack: Open-source Mobile
Backend Powered by Node.js

Open Source and extensible by design
☁ On-premise or in the cloud
 Leverage existing data and services
 Dynamically save data from mobile
clients
Push and Geolocation services built-in
 Dynamic REST and client APIs for
iOS and Android
Follow us
•
•
•
•

Repo: https://github.com/strongloop/loopback
Blog: http://strongloop.com/strongblog/
Email: callback@strongloop.com
Twitter: @strongloop, @cyberfeng

More Related Content

What's hot

Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)
Ako Kaman
 

What's hot (20)

StrongLoop Node.js API Security & Customization
StrongLoop Node.js API Security & CustomizationStrongLoop Node.js API Security & Customization
StrongLoop Node.js API Security & Customization
 
Node's Event Loop From the Inside Out - Sam Roberts, IBM
Node's Event Loop From the Inside Out - Sam Roberts, IBMNode's Event Loop From the Inside Out - Sam Roberts, IBM
Node's Event Loop From the Inside Out - Sam Roberts, IBM
 
Triangle Node.js DevOps
Triangle Node.js DevOpsTriangle Node.js DevOps
Triangle Node.js DevOps
 
Toronto node js_meetup
Toronto node js_meetupToronto node js_meetup
Toronto node js_meetup
 
Azure functions
Azure functionsAzure functions
Azure functions
 
OpenSource Node.js API Framework and Server for Enterprise
OpenSource Node.js API Framework and Server for EnterpriseOpenSource Node.js API Framework and Server for Enterprise
OpenSource Node.js API Framework and Server for Enterprise
 
Web Application Frameworks (WAF)
Web Application Frameworks (WAF)Web Application Frameworks (WAF)
Web Application Frameworks (WAF)
 
Will the Real Public API Please Stand Up? Amir Zuker
Will the Real Public API Please Stand Up? Amir ZukerWill the Real Public API Please Stand Up? Amir Zuker
Will the Real Public API Please Stand Up? Amir Zuker
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
 
Intro to Azure Static Web Apps
Intro to Azure Static Web AppsIntro to Azure Static Web Apps
Intro to Azure Static Web Apps
 
Getting Started With Angular
Getting Started With AngularGetting Started With Angular
Getting Started With Angular
 
Azure Web Apps Advanced Security
Azure Web Apps Advanced SecurityAzure Web Apps Advanced Security
Azure Web Apps Advanced Security
 
Azure functions serverless
Azure functions serverlessAzure functions serverless
Azure functions serverless
 
[AWS Hero 스페셜] 서버리스 기반 검색 서비스 구축하기 - 이상현(스마일벤처스) :: AWS Community Day Online ...
[AWS Hero 스페셜] 서버리스 기반 검색 서비스 구축하기 - 이상현(스마일벤처스) :: AWS Community Day Online ...[AWS Hero 스페셜] 서버리스 기반 검색 서비스 구축하기 - 이상현(스마일벤처스) :: AWS Community Day Online ...
[AWS Hero 스페셜] 서버리스 기반 검색 서비스 구축하기 - 이상현(스마일벤처스) :: AWS Community Day Online ...
 
Infrastructure as Code on Azure - Show your Bicep! v0.2 - .NetConf 2020 by Do...
Infrastructure as Code on Azure - Show your Bicep! v0.2 - .NetConf 2020 by Do...Infrastructure as Code on Azure - Show your Bicep! v0.2 - .NetConf 2020 by Do...
Infrastructure as Code on Azure - Show your Bicep! v0.2 - .NetConf 2020 by Do...
 
TechTalk@Vingle - Serverless
TechTalk@Vingle - ServerlessTechTalk@Vingle - Serverless
TechTalk@Vingle - Serverless
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
 
Angular universal
Angular universalAngular universal
Angular universal
 

Viewers also liked

Viewers also liked (17)

Getting Started with the Node.js LoopBack APi Framework
Getting Started with the Node.js LoopBack APi FrameworkGetting Started with the Node.js LoopBack APi Framework
Getting Started with the Node.js LoopBack APi Framework
 
Authenticating and Securing Node.js APIs
Authenticating and Securing Node.js APIsAuthenticating and Securing Node.js APIs
Authenticating and Securing Node.js APIs
 
Scaling Your Microservices With LoopBack
Scaling Your Microservices With LoopBackScaling Your Microservices With LoopBack
Scaling Your Microservices With LoopBack
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
Node.js гэж юу вэ?
Node.js гэж юу вэ?Node.js гэж юу вэ?
Node.js гэж юу вэ?
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 
Create simple api using node js
Create simple api using node jsCreate simple api using node js
Create simple api using node js
 
Micro Gateways are a Big Deal
Micro Gateways are a Big DealMicro Gateways are a Big Deal
Micro Gateways are a Big Deal
 
Loopback
LoopbackLoopback
Loopback
 
Top Node.js Metrics to Watch
Top Node.js Metrics to WatchTop Node.js Metrics to Watch
Top Node.js Metrics to Watch
 
Node.js Frameworks & Design Patterns Webinar
Node.js Frameworks & Design Patterns WebinarNode.js Frameworks & Design Patterns Webinar
Node.js Frameworks & Design Patterns Webinar
 
HTTP, JSON, REST e AJAX com AngularJS
HTTP, JSON, REST e AJAX com AngularJSHTTP, JSON, REST e AJAX com AngularJS
HTTP, JSON, REST e AJAX com AngularJS
 
Streaming Patterns Revolutionary Architectures with the Kafka API
Streaming Patterns Revolutionary Architectures with the Kafka APIStreaming Patterns Revolutionary Architectures with the Kafka API
Streaming Patterns Revolutionary Architectures with the Kafka API
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
Microservices with Node.js and RabbitMQ
Microservices with Node.js and RabbitMQMicroservices with Node.js and RabbitMQ
Microservices with Node.js and RabbitMQ
 
Best Practices for API Security
Best Practices for API SecurityBest Practices for API Security
Best Practices for API Security
 
Deep-Dive: API Security in the Digital Age
Deep-Dive: API Security in the Digital AgeDeep-Dive: API Security in the Digital Age
Deep-Dive: API Security in the Digital Age
 

Similar to Building a Node.js API backend with LoopBack in 5 Minutes

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 

Similar to Building a Node.js API backend with LoopBack in 5 Minutes (20)

(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
(GAM301) Real-Time Game Analytics with Amazon Kinesis, Amazon Redshift, and A...
 
LoopbackJS the intro
LoopbackJS the introLoopbackJS the intro
LoopbackJS the intro
 
OpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 WebinarOpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 Webinar
 
Hilfe, wir brauchen ein Frontend
Hilfe, wir brauchen ein FrontendHilfe, wir brauchen ein Frontend
Hilfe, wir brauchen ein Frontend
 
오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread
오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread
오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread
 
Bigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_appBigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_app
 
Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655
Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655
Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
AWS as platform for scalable applications
AWS as platform for scalable applicationsAWS as platform for scalable applications
AWS as platform for scalable applications
 
Integrate MongoDB & SQL data with a single REST API
Integrate MongoDB & SQL data with a single REST APIIntegrate MongoDB & SQL data with a single REST API
Integrate MongoDB & SQL data with a single REST API
 
Best Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data LayersBest Practices for Building Open Source Data Layers
Best Practices for Building Open Source Data Layers
 
Gaming on AWS - 1. AWS로 글로벌 게임 런칭하기 - 장르별 아키텍처 중심
Gaming on AWS - 1. AWS로 글로벌 게임 런칭하기 - 장르별 아키텍처 중심Gaming on AWS - 1. AWS로 글로벌 게임 런칭하기 - 장르별 아키텍처 중심
Gaming on AWS - 1. AWS로 글로벌 게임 런칭하기 - 장르별 아키텍처 중심
 
MongoDB Server Provisioning - From 2 Months to 2 Minutes
MongoDB Server Provisioning - From 2 Months to 2 MinutesMongoDB Server Provisioning - From 2 Months to 2 Minutes
MongoDB Server Provisioning - From 2 Months to 2 Minutes
 
The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)
 
Working with PowerVC via its REST APIs
Working with PowerVC via its REST APIsWorking with PowerVC via its REST APIs
Working with PowerVC via its REST APIs
 
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
AWS re:Invent 2016: Deep-Dive: Native, Hybrid and Web patterns with Serverles...
 
Externally Testing Modern AD Domains - Arcticcon
Externally Testing Modern AD Domains - ArcticconExternally Testing Modern AD Domains - Arcticcon
Externally Testing Modern AD Domains - Arcticcon
 
Node.CQ - Creating Real-time Data Mashups with Node.JS and Adobe CQ
Node.CQ - Creating Real-time Data Mashups with Node.JS and Adobe CQNode.CQ - Creating Real-time Data Mashups with Node.JS and Adobe CQ
Node.CQ - Creating Real-time Data Mashups with Node.JS and Adobe CQ
 
Spring Boot & Spring Cloud on Pivotal Application Service - Alexandre Roman
Spring Boot & Spring Cloud on Pivotal Application Service - Alexandre RomanSpring Boot & Spring Cloud on Pivotal Application Service - Alexandre Roman
Spring Boot & Spring Cloud on Pivotal Application Service - Alexandre Roman
 
Getting Started with Real-time Analytics
Getting Started with Real-time AnalyticsGetting Started with Real-time Analytics
Getting Started with Real-time Analytics
 

More from Raymond Feng

OSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache TuscanyOSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache Tuscany
Raymond Feng
 

More from Raymond Feng (7)

Data Binding Unleashed for Composite Applications
Data Binding Unleashed for Composite ApplicationsData Binding Unleashed for Composite Applications
Data Binding Unleashed for Composite Applications
 
Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...
Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...
Building Flexible APIs for Web 2.x/Cloud Applications (JavaOne 2011 Session ...
 
RESTful SCA with Apache Tuscany
RESTful SCA with Apache TuscanyRESTful SCA with Apache Tuscany
RESTful SCA with Apache Tuscany
 
Data Binding Unleashed for Composite Applications
Data Binding Unleashed for Composite ApplicationsData Binding Unleashed for Composite Applications
Data Binding Unleashed for Composite Applications
 
Apache Tuscany 2.x Extensibility And SPIs
Apache Tuscany 2.x Extensibility And SPIsApache Tuscany 2.x Extensibility And SPIs
Apache Tuscany 2.x Extensibility And SPIs
 
OSGi Enablement For Apache Tuscany
OSGi Enablement For Apache TuscanyOSGi Enablement For Apache Tuscany
OSGi Enablement For Apache Tuscany
 
OSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache TuscanyOSGi Remote Services With SCA using Apache Tuscany
OSGi Remote Services With SCA using Apache Tuscany
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

Building a Node.js API backend with LoopBack in 5 Minutes

  • 1. Building an API backend with LoopBack in 5 Minutes Raymond Feng Co-Founder and Architect StrongLoop, Inc.
  • 2. Why do I need an API backend? • Build mobile applications that need to produce/consume data – Account for gamers. • Provision a backend that provides APIs/SDKs – REST, JS, iOS, Android • Pick a database – MongoDB, MySQL, Oracle, PostgreSQL, … – CRUD and beyond, queries and relations, …
  • 3. Let’s scaffold a Node.js API server 1. 2. 3. 4. 5. npm install -g strong-cli (only once) slc lb project loopback-mysql-example cd loopback-mysql-example slc lb datasource mysql --connector mysql slc lb model account -i --data-source mysql – – – – email: string - The email id for the account level: number - The game level you are in created: date - The date your account is created modified: date - The date your account is updated 6. npm install loopback-connector-mysql --save
  • 4. Connect to MySQL • Update datasources.json "mysql": { "connector": "mysql", "host": "myserver", "port": 3306, "database": "demo", "username": "demo", "password": "password" }
  • 5. Ready to go! • Start the server – node app – http://localhost:3000/explorer • Create table in MySQL and add test data – node create-test-data.js – http://localhost:3000/api/accounts – http://localhost:3000/api/accounts/1 • Discover models from MySQL tables – node discover.js
  • 6. Show me the code • https://github.com/strongloopcommunity/loopback-mysql-example
  • 7. Switch to MongoDB • datasources.json "mongodb": { "connector": "mongodb", "host": "server", "port": 27017, "database": "demo", "username": "demo", "password": "password" } • models.json – Change the dataSource property for Account model to be “mongodb”
  • 9. LoopBack: Open-source Mobile Backend Powered by Node.js Open Source and extensible by design ☁ On-premise or in the cloud  Leverage existing data and services  Dynamically save data from mobile clients Push and Geolocation services built-in  Dynamic REST and client APIs for iOS and Android
  • 10. Follow us • • • • Repo: https://github.com/strongloop/loopback Blog: http://strongloop.com/strongblog/ Email: callback@strongloop.com Twitter: @strongloop, @cyberfeng