Scaffolding RESTful APIs

Our Yeoman generator helps us in scaffolding our endpoint APIs. It creates most of the files that we are going to need.

Let's go ahead and create our products' API endpoint. In the next chapter, we are going to use what we build here, and connect it to our AngularJS app. The Yeoman generator has a command for that:

$ yo angular-fullstack:endpoint product

? What will the url of your endpoint be? /api/products
   create server/api/product/product.controller.js
   create server/api/product/product.events.js
   create server/api/product/product.integration.js
   create server/api/product/product.model.js
   create server/api/product/product.socket.js
   create server/api/product/index.js
   create server/api/product/index.spec.js

This command will create some files needed for our API. Run grunt test (and mongod); verify that all the tests are passed. That is all we need to have a working products API backed-up in MongoDB. Don't worry, we are going to unveil the magic of each file in turn.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.27.232