Middleware for mongo poll server