Refactored from sails to vanilla node