moved all middleware from coffee to js