Add initAPI.js in new middlewar dir; update index.js to call new initAPI module; improve loop interation;