Company: Unicult_8oct
Difficulty: medium
Problem Description You are tasked with building a reporting feature API for an e-commerce admin dashboard. The objective is to retrieve a report of the top 5 customers based on their total historical spending. The API must return each customer's name, email, total amount spent, total number of orders, and a list of their 3 most recent orders (including order ID, amount, and date). You are required to implement this endpoint using Node.js and the MongoDB aggregation framework. Endpoints GET /api/admin/reports/top-customers Request Format No request body or query parameters are required. The endpoint statically fetches the top 5 customers and their 3 most recent orders. Assume an Authorization header with a Bearer token is provided for admin authentication. Response Format The response should be a JSON array containing up to 5 customer objects, ordered by totalSpent in descending order. [ { "customerId": "ObjectId", "name": "String", "email": "String", "totalSpent": "Number", "totalOrde