Partially implements #9 by adding functionality for sorting by event.
Added a security middleware to check for illegal event_types.