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

  • 6,781 views
Uploaded on

LoopBack is an open source API framework built on top of Express optimized for mobile and web. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services …

LoopBack is an open source API framework built on top of Express optimized for mobile and web. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services and data, connect using JS, iOS & Android SDKs.

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
6,781
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
27
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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”
  • 8. What’s the magic? LoopBack!
  • 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