Friday, February 6, 2015

Strong Loop - Rest Connector

Why would any ways Loopback API's be involved in the Ecommerce technology. But they do. Loopback API's are needed when we would like to connect the Ecommerce platforms as WCS (websphere Commerce) , ATG or Hybris to the Enterprise Content Management system , Inventory Mangement system etc.  I am providing the basic steps , here to set up Strong Loop API with Rest Connector and start using it .

1. First get the Core concepts 


2. Install StrongLoop and perform Basic Actions (python is must as well as node.js)


a) npm install -g strongloop
b) Create the Project


3. install the Rest Connector

$ npm install loopback-connector-rest --save


4. Add Data Source
slc loopback:datasource

5. Configure the Data Source
6. Enter the Data source name and the connector.
7. Update the generated DataSource.Json file ( write the functions and service endpoints your Model is going to use)

8. Add model for CRUD operations 

slc loopback:model – create the model
slc run

After these steps are done . Your Model will be created with all the Endpoints you have mentioned in the data sources.json file.
In case you want not to use all endpoints but only some of the fucntions  . You need to update the model-config.json file present in <loopback-projectpath>/server/

for eg .

  "Stock": {
    "dataSource": "HybrisRestConnector",
    "public": true
  }
Changed to 
  "Stock": {
    "dataSource": "db",
    "public": true
  }

Then write the needed javascript in <model>.js  present in <loopback-projectpath>/common/models ( for eg. stock.js)  file to work with your model.