Rafactored conversion to JSON of body content into middleware modules to simplify router.js.