restructuring middleware to allow for custom path to public folder