Pagination for javascript and nodejs