Added subgoal endpoints to subgoal.js and added documentation