Moved messages.js to middleware folder