MVC way to introduce Sails.js - node.js framework
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

MVC way to introduce Sails.js - node.js framework

on

  • 3,892 views

introduce Sails.js in MVC way, we all know MVC for web development, let looking for Sails.js for Node.js Web application MVC infrastructure and development.

introduce Sails.js in MVC way, we all know MVC for web development, let looking for Sails.js for Node.js Web application MVC infrastructure and development.

Statistics

Views

Total Views
3,892
Views on SlideShare
1,678
Embed Views
2,214

Actions

Likes
8
Downloads
26
Comments
0

6 Embeds 2,214

http://www.scoop.it 2183
http://www.slideee.com 22
https://twitter.com 6
http://plus.url.google.com 1
http://webcache.googleusercontent.com 1
http://translate.googleusercontent.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

MVC way to introduce Sails.js - node.js framework Presentation Transcript

  • 1. MVC way to introduce sails.js - Caesar Chi http://sailsjs.org/#! Monday, May 12, 14
  • 2. Web, MVC Monday, May 12, 14
  • 3. Monday, May 12, 14
  • 4. Monday, May 12, 14
  • 5. Rails like framework, but extends node.js feature Monday, May 12, 14
  • 6. http://sailsjs.org/ Monday, May 12, 14
  • 7. Sails.js •Auto Routing •Express base •Scaffolding •Socket.io support •Restful blueprint Monday, May 12, 14
  • 8. Support and Enhance Monday, May 12, 14
  • 9. Monday, May 12, 14
  • 10. Blueprint default support, you do not key in CRUD https://github.com/hankejh/blueprint Monday, May 12, 14
  • 11. Model module, use Waterline https://github.com/balderdashy/waterline Monday, May 12, 14
  • 12. Route Setting is *ucking EASY Monday, May 12, 14
  • 13. Scaffolding create controllers models in 1 second Monday, May 12, 14
  • 14. Blueprint built-in Restful service in 1 second Monday, May 12, 14
  • 15. How to start? Monday, May 12, 14
  • 16. npm install -g sails cli Monday, May 12, 14
  • 17. Quick start Monday, May 12, 14
  • 18. run app • cd project • node app • sails lift Monday, May 12, 14
  • 19. Sails.js command line Monday, May 12, 14
  • 20. Sails generate Controller Model action ... cli Monday, May 12, 14
  • 21. Generate sails generate controller model name blueprints include cli Monday, May 12, 14
  • 22. Generate(cli) • Model • path: • /api/model • Controller • Path: • /api/controller Monday, May 12, 14
  • 23. Generate(cli) • Model • path: • /api/model • Controller • Path: • /api/controllerModel, Controller will be global object Monday, May 12, 14
  • 24. Controller http://sailsjs.org/#!documentation/controllers Monday, May 12, 14
  • 25. sails generate controller Comment create destroy tag like cli Monday, May 12, 14
  • 26. sails generate controller Comment create destroy tag like cli Request, Response Monday, May 12, 14
  • 27. CommentController.js Monday, May 12, 14
  • 28. CommentController.js This is Model object Monday, May 12, 14
  • 29. Controller • /api/controllers/ • http://sailsjs.org/#!documentation/controllers Monday, May 12, 14
  • 30. View Monday, May 12, 14
  • 31. View • View -> as a render function • Path: • /view/... • Support • ejs (default) • jade Monday, May 12, 14
  • 32. View • View -> as a render function • Path: • /view/... • Support • ejs (default) • jade ejs (default) Monday, May 12, 14
  • 33. http://embeddedjs.com/ Monday, May 12, 14
  • 34. Monday, May 12, 14
  • 35. html layout html body (content) Monday, May 12, 14
  • 36. view path response.view() controller Monday, May 12, 14
  • 37. parameters response.view() controller Monday, May 12, 14
  • 38. View Partials Monday, May 12, 14
  • 39. Response view • res.view() = res.render(); • res.send({ some: 'json' }); • res.json({ user: 'tj' }); • res.redirect('/', 301); Monday, May 12, 14
  • 40. Route http://sailsjs.org/#!documentation/routes Monday, May 12, 14
  • 41. Route • Route • Path • /api/routes.js Monday, May 12, 14
  • 42. Route (default) default follow blueprint URL route Monday, May 12, 14
  • 43. Route (default) default follow blueprint Controller name Controller action (function) Monday, May 12, 14
  • 44. view point to route URL route View route Monday, May 12, 14
  • 45. Route(default) Monday, May 12, 14
  • 46. Route and action config/Route.js Monday, May 12, 14
  • 47. Model Monday, May 12, 14
  • 48. Model • file path -> api/models • Capital naming • Set schema and rule. • ORM like • you can use multi-adapter Monday, May 12, 14
  • 49. example, api/models/Post.js Monday, May 12, 14
  • 50. example, api/models/Post.js defined key & attribute Monday, May 12, 14
  • 51. example, controller call Post model Monday, May 12, 14
  • 52. example, controller call Post model model name Monday, May 12, 14
  • 53. example, controller call Post model model behavior Monday, May 12, 14
  • 54. example, controller call Post model new data Monday, May 12, 14
  • 55. example, controller call Post model success callback & response Monday, May 12, 14
  • 56. Model document http://sailsjs.org/#!documentation/models Monday, May 12, 14
  • 57. Controller, Model, Service, will be Global object Monday, May 12, 14
  • 58. MVC way example https://github.com/nodejs-tw/example-week3 Monday, May 12, 14
  • 59. @clonncd Monday, May 12, 14
  • 60. Sails.js • sails.js version is 0.9.x • the model part and service, we will talk in another chapter. • keep coding, be passions. Monday, May 12, 14