move middleware to server folder