@lefnire => Clean up middleware

This moves two large functions into a separate file for middleware. Just makes the express middleware much cleaner and easier to read + update.

**Don't** merge this until https://github.com/lefnire/habitrpg/pull/430 is merged in as this is branched off of that. (That shouldn't be merged yet, either – see my email).