Update middleware.js

Update validation function to reply with an error instead of an object.
Merge pull request #6 from liquidninja24/master

Update middleware.js