SlideShare a Scribd company logo
Intro Installation and configuration Query data Conclusion
Standardized API Development
Nicolas De Smyter
FDS
March 17, 2017
Intro Installation and configuration Query data Conclusion
1 Intro
2 Installation and configuration
First setup
Configure database
Configure model
User implemented method
Start API server
3 Query data
4 Conclusion
Further reading
Intro Installation and configuration Query data Conclusion
Loopback
LoopBack is a highly-extensible, open-source Node.js framework
that enables you to create dynamic end-to-end REST APIs with
little or no coding.
Intro Installation and configuration Query data Conclusion
First setup
$ npm install -g loopback-cli
$ lb
Intro Installation and configuration Query data Conclusion
Configure database
$ lb datasource
? Enter the data-source name: postgres-db
? Select the connector for oracledb: PostgreSQL
Connector specific configuration:
? Connection String url to override other settings:
postgres://postgres:postgres@localhost/mantis
? host: localhost
? port: 5432
? user: postgres
? password: ********
? database: mantis
? install loopback-connector-postgresql@^2.4 Yes
Intro Installation and configuration Query data Conclusion
Configure model
$ lb model
? Enter the model name: dive
? Select the data-source to attach dive to:
postgres-db
? Select model’s base class PersistedModel
? Expose dive via the REST API? Yes
? Custom plural form (used to build REST URL):
dives
? Common model or server only? common
Let’s add some dive properties now.
Intro Installation and configuration Query data Conclusion
Configure model properties
Enter an empty property name when done.
? Property name: id
invoke loopback:property
? Property type: number
? Required? Yes
? Default value [leave empty for none]:
Intro Installation and configuration Query data Conclusion
Link models
$ lb relation
? Name of the model to create the relationship
from: dive
? Relation type: has many
? Name of the model to create a relationship with:
participant
? Name for the relation: participants
? Custom foreign key: dive id
? Whether a "through" model is required? No
Intro Installation and configuration Query data Conclusion
Existing methods
Every model:
create
find
findOne
findById
updateAll
createUpdates
destroyAll
...
Intro Installation and configuration Query data Conclusion
Remote method
Dive. divesByCountry = function (country , cb) {
var Location = app.models.location;
Location.find ({ fields: ["id"], where: {location: country }}, function (err ,
locations) {
var locationIds = [];
for (var i = 0, length = locations.length; i < length; i++) {
locationIds.push(locations[i].id);
}
Dive.find ({ where: { location_id : {"inq": locationIds }}}, cb);
})
};
Dive. remoteMethod (’divesByCountry ’, {
accepts: {arg: ’country ’, type: ’string ’},
returns: {arg: ’dives ’, type: ’Dive []’},
description: ’List the dives that are organized in a specific country ’,
http: {verb: ’get’}
});
Intro Installation and configuration Query data Conclusion
Access control
$ lb acl
Built-in, using authentication tokens
Security per method or end-point
*, READ, WRITE, EXECUTE
DENY, ALLOW
$everyone, $authenticated, $unauthenticated, $owner
Intro Installation and configuration Query data Conclusion
Start API server
$ node .
In debugging mode:
$ DEBUG=loopback:connector:postgresql node .
Intro Installation and configuration Query data Conclusion
Query data
Use the built-in explorer: http://localhost:3000/explorer
Intro Installation and configuration Query data Conclusion
Filter
fields
where
include
order
offset
limit
Intro Installation and configuration Query data Conclusion
Query data - Request
Intro Installation and configuration Query data Conclusion
Query data - Response
Intro Installation and configuration Query data Conclusion
Further reading
Boot scripts
Input validation
Changes to core code needed for geographic support
Intro Installation and configuration Query data Conclusion
IBM API Connect
– Betalend
www-03.ibm.com/software/products/en/api-connect
Intro Installation and configuration Query data Conclusion
Conclusion
+ Easy to configure and use
+ Different database types supported
+ Highly configurable
+ Good and useful documentation with examples
+ Input validation
– No native geographic support (code changes)
Intro Installation and configuration Query data Conclusion
The End
Questions ?
All code and presentation:
https://github.com/ndsmyter/loopback-brownbag
Nicolas.DeSmyter@esfds.com

More Related Content

PDF
Nodejs - A quick tour (v4)
PDF
Nodejs - Should Ruby Developers Care?
PDF
Node.js - A Quick Tour
PDF
Nodejs - A-quick-tour-v3
PDF
Nodejs - A quick tour (v5)
KEY
Node.js - As a networking tool
PPTX
Rails with MongoDB - RORLab 47th
PDF
iOS VoIP待ち受けの仕組み
Nodejs - A quick tour (v4)
Nodejs - Should Ruby Developers Care?
Node.js - A Quick Tour
Nodejs - A-quick-tour-v3
Nodejs - A quick tour (v5)
Node.js - As a networking tool
Rails with MongoDB - RORLab 47th
iOS VoIP待ち受けの仕組み

What's hot (20)

PPTX
Creating Reusable Puppet Profiles
PDF
Hujs 总结
PDF
Nodejs - A quick tour (v6)
KEY
Node.js - A practical introduction (v2)
PDF
Web前端性能优化 2014
PDF
Realm.io par Clement Sauvage
PDF
Dirty - How simple is your database?
PDF
Integrating icinga2 and the HashiCorp suite
PDF
Nodejs a-practical-introduction-oredev
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
PDF
Big Master Data PHP BLT #1
PDF
Nodejs Explained with Examples
PPT
Building your first Node app with Connect & Express
KEY
A million connections and beyond - Node.js at scale
KEY
Node.js - Best practices
PPTX
Getting Started with MongoDB and NodeJS
PPTX
Scalable network applications, event-driven - Node JS
PDF
Node.js - A Quick Tour II
PPTX
Codable routing
PPTX
Elasticsearch 설치 및 기본 활용
Creating Reusable Puppet Profiles
Hujs 总结
Nodejs - A quick tour (v6)
Node.js - A practical introduction (v2)
Web前端性能优化 2014
Realm.io par Clement Sauvage
Dirty - How simple is your database?
Integrating icinga2 and the HashiCorp suite
Nodejs a-practical-introduction-oredev
Event-driven IO server-side JavaScript environment based on V8 Engine
Big Master Data PHP BLT #1
Nodejs Explained with Examples
Building your first Node app with Connect & Express
A million connections and beyond - Node.js at scale
Node.js - Best practices
Getting Started with MongoDB and NodeJS
Scalable network applications, event-driven - Node JS
Node.js - A Quick Tour II
Codable routing
Elasticsearch 설치 및 기본 활용
Ad

Similar to Standardized API Development using Node.js (20)

PPTX
Working with LoopBack Models
PPTX
LoopbackJS the intro
PPTX
PostgreSQL, MongoDb, Express, React, Structured
PPTX
Learn Developing REST API in Node.js using LoopBack Framework
PDF
Nosql hands on handout 04
PDF
Rapid app building with loopback framework
PDF
StrongLoop Node.js API Security & Customization
PDF
Learn backend java script
PDF
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
PDF
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
PDF
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
ODP
Intravert Server side processing for Cassandra
ODP
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
PPTX
Geoindexing with MongoDB
PDF
Create and Manage APIs with API Connect, Swagger and Bluemix
PDF
Sustainable Software Decisions for Long-term Projects, AGU Fall Meeting 2013
PDF
Java EE 6 and NoSQL Workshop DevFest Austria
PDF
CouchDB Talk JChris NYC
PPTX
PostgreSQL - Object Relational Database
PPTX
Building a Node.js API backend with LoopBack in 5 Minutes
Working with LoopBack Models
LoopbackJS the intro
PostgreSQL, MongoDb, Express, React, Structured
Learn Developing REST API in Node.js using LoopBack Framework
Nosql hands on handout 04
Rapid app building with loopback framework
StrongLoop Node.js API Security & Customization
Learn backend java script
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
Intravert Server side processing for Cassandra
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
Geoindexing with MongoDB
Create and Manage APIs with API Connect, Swagger and Bluemix
Sustainable Software Decisions for Long-term Projects, AGU Fall Meeting 2013
Java EE 6 and NoSQL Workshop DevFest Austria
CouchDB Talk JChris NYC
PostgreSQL - Object Relational Database
Building a Node.js API backend with LoopBack in 5 Minutes
Ad

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Approach and Philosophy of On baking technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Big Data Technologies - Introduction.pptx
PPT
Teaching material agriculture food technology
PPTX
Cloud computing and distributed systems.
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PDF
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
Approach and Philosophy of On baking technology
MIND Revenue Release Quarter 2 2025 Press Release
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Review of recent advances in non-invasive hemoglobin estimation
Big Data Technologies - Introduction.pptx
Teaching material agriculture food technology
Cloud computing and distributed systems.
sap open course for s4hana steps from ECC to s4
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
Reach Out and Touch Someone: Haptics and Empathic Computing
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
Electronic commerce courselecture one. Pdf

Standardized API Development using Node.js

  • 1. Intro Installation and configuration Query data Conclusion Standardized API Development Nicolas De Smyter FDS March 17, 2017
  • 2. Intro Installation and configuration Query data Conclusion 1 Intro 2 Installation and configuration First setup Configure database Configure model User implemented method Start API server 3 Query data 4 Conclusion Further reading
  • 3. Intro Installation and configuration Query data Conclusion Loopback LoopBack is a highly-extensible, open-source Node.js framework that enables you to create dynamic end-to-end REST APIs with little or no coding.
  • 4. Intro Installation and configuration Query data Conclusion First setup $ npm install -g loopback-cli $ lb
  • 5. Intro Installation and configuration Query data Conclusion Configure database $ lb datasource ? Enter the data-source name: postgres-db ? Select the connector for oracledb: PostgreSQL Connector specific configuration: ? Connection String url to override other settings: postgres://postgres:postgres@localhost/mantis ? host: localhost ? port: 5432 ? user: postgres ? password: ******** ? database: mantis ? install loopback-connector-postgresql@^2.4 Yes
  • 6. Intro Installation and configuration Query data Conclusion Configure model $ lb model ? Enter the model name: dive ? Select the data-source to attach dive to: postgres-db ? Select model’s base class PersistedModel ? Expose dive via the REST API? Yes ? Custom plural form (used to build REST URL): dives ? Common model or server only? common Let’s add some dive properties now.
  • 7. Intro Installation and configuration Query data Conclusion Configure model properties Enter an empty property name when done. ? Property name: id invoke loopback:property ? Property type: number ? Required? Yes ? Default value [leave empty for none]:
  • 8. Intro Installation and configuration Query data Conclusion Link models $ lb relation ? Name of the model to create the relationship from: dive ? Relation type: has many ? Name of the model to create a relationship with: participant ? Name for the relation: participants ? Custom foreign key: dive id ? Whether a "through" model is required? No
  • 9. Intro Installation and configuration Query data Conclusion Existing methods Every model: create find findOne findById updateAll createUpdates destroyAll ...
  • 10. Intro Installation and configuration Query data Conclusion Remote method Dive. divesByCountry = function (country , cb) { var Location = app.models.location; Location.find ({ fields: ["id"], where: {location: country }}, function (err , locations) { var locationIds = []; for (var i = 0, length = locations.length; i < length; i++) { locationIds.push(locations[i].id); } Dive.find ({ where: { location_id : {"inq": locationIds }}}, cb); }) }; Dive. remoteMethod (’divesByCountry ’, { accepts: {arg: ’country ’, type: ’string ’}, returns: {arg: ’dives ’, type: ’Dive []’}, description: ’List the dives that are organized in a specific country ’, http: {verb: ’get’} });
  • 11. Intro Installation and configuration Query data Conclusion Access control $ lb acl Built-in, using authentication tokens Security per method or end-point *, READ, WRITE, EXECUTE DENY, ALLOW $everyone, $authenticated, $unauthenticated, $owner
  • 12. Intro Installation and configuration Query data Conclusion Start API server $ node . In debugging mode: $ DEBUG=loopback:connector:postgresql node .
  • 13. Intro Installation and configuration Query data Conclusion Query data Use the built-in explorer: http://localhost:3000/explorer
  • 14. Intro Installation and configuration Query data Conclusion Filter fields where include order offset limit
  • 15. Intro Installation and configuration Query data Conclusion Query data - Request
  • 16. Intro Installation and configuration Query data Conclusion Query data - Response
  • 17. Intro Installation and configuration Query data Conclusion Further reading Boot scripts Input validation Changes to core code needed for geographic support
  • 18. Intro Installation and configuration Query data Conclusion IBM API Connect – Betalend www-03.ibm.com/software/products/en/api-connect
  • 19. Intro Installation and configuration Query data Conclusion Conclusion + Easy to configure and use + Different database types supported + Highly configurable + Good and useful documentation with examples + Input validation – No native geographic support (code changes)
  • 20. Intro Installation and configuration Query data Conclusion The End Questions ? All code and presentation: https://github.com/ndsmyter/loopback-brownbag Nicolas.DeSmyter@esfds.com