using Microsoft.Extensions.DependencyInjection;

namespace JWTService.Extensions {
  public static class ServiceCollectionExtensions {
    public static void RegisterJWTService(this IServiceCollection services, IJWTServiceConfig appSettings) {
      var config = appSettings.JwtConfig;

      if(config == null) throw new NullReferenceException();

      services.AddSingleton<IJwtConfig>(x => config);
      services.AddSingleton<IJWTService, JWTService>();
    }
  }
}
