Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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


Published 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 and data, connect using JS, iOS & Android SDKs.

Published in: Technology, Education
  • Follow the link, new dating source: ❤❤❤ ❤❤❤
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ♥♥♥ ♥♥♥
    Are you sure you want to  Yes  No
    Your message goes here

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

  1. 1. Building an API backend with LoopBack in 5 Minutes Raymond Feng Co-Founder and Architect StrongLoop, Inc.
  2. 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. 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. 4. Connect to MySQL • Update datasources.json "mysql": { "connector": "mysql", "host": "myserver", "port": 3306, "database": "demo", "username": "demo", "password": "password" }
  5. 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. 6. Show me the code •
  7. 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. 8. What’s the magic? LoopBack!
  9. 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. 10. Follow us • • • • Repo: Blog: Email: Twitter: @strongloop, @cyberfeng