objCompositionv3

by dougiei

JavaScript

//based on the 'name' do a look up to get specific value

const apiSettings = (name) => {
 
 
 let settings ={
  name,
  serviceName : "/auditserviceapi/auditrecord/",
  portId : ":31227",
  hostId: "http://10.180.24.240",
  modelId :"",
  comparatorId :"",
  searchType :"default" // determines how we ad any quey parametrs to the URL
 }
 
 
 return Object.assign(settings);
}

// Simply return the service URl
// Future should validate expression is valid?/

const apiEndpoint =  (mysettings) => {
 return ( mysettings.hostId+mysettings.portId+mysettings.serviceName);
}


const defineModel = (settings) =>{}

const defineCollection = () => {}


const fetchCollection = () => {

} 

const apiFactory = () =>{
  mySettings = apiSettings('Audit');
  myEndpoint = apiEndpoint(mySettings);
  myModel  = defineModel(mySettings);
  myCollection = defineCollection ()
  
  console.log(myEndpoint);
  
 
}


// simple testing

mySettings = apiSettings('Audit');
myEndpoint = apiEndpoint(mySettings);
console.log(myEndpoint);

myFactory = apiFactory('Audit');
console.log(myFactory);