using Interfaces;
using Nancy;

namespace RaceLapTimer.ApiControllers
{
    public class PilotsApiModule : NancyModule
    {
        private readonly IDbProvider _provider;
        public PilotsApiModule(IDbProvider provider) : base("/api/pilots")
        {
            _provider = provider;
            Get[""] = args => GetPilotsList();
        }

        private dynamic GetPilotsList()
        {
            return Response.AsJson(new { data = _provider.GetPilotsList() });
        }
    }
}