static async Task Main(string[] _args)
 {
     var client    = TmdbClient.Default();
     var populator = new MoviePopulator("./data/movie_ids_10_01_2020.json", client);
     var ingester  = new IngestTmdb(populator);
     await ingester.Ingest();
 }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMemoryCache();
            services.AddMiniProfiler(options => {
                options.RouteBasePath   = "/profiler";
                options.EnableDebugMode = true;
            }).AddEntityFramework();
            services.AddControllers();

            services.AddDbContext <ApplicationDbContext>(options => ApplicationDbContext.UseDefaultOptions(options));
            services.AddScoped <ISessionRepository, SessionRepository>();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <IGenreRepository, GenreRepository>();
            services.AddScoped <ITitleRepository, TitleRepository>();
            services.AddScoped <ICurrentUserAccessor, CurrentUserAccessor>();
            services.AddSingleton(services => TmdbClient.Default(services.GetService <IMemoryCache>()));
            services.AddSingleton <MovieClient>();
            services.AddSingleton <MovieMeta>();


            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddIdentity <ApplicationUser, IdentityRole>(options => {
                options.User.RequireUniqueEmail = false;
            })
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            // https://docs.microsoft.com/en-us/aspnet/core/web-api/handle-errors?view=aspnetcore-3.1
            services.AddControllersWithViews(options => {
                options.Filters.Add(new ValidationErrorHandler());
                options.Filters.Add(new NotificationHandler());
            });
            services.AddRazorPages();

            services.AddMediatR(typeof(Core.UseCases.Session.Create));
            AssemblyScanner.FindValidatorsInAssembly(typeof(Core.UseCases.Session.Create).Assembly)
            .ForEach(item => services.AddScoped(item.InterfaceType, item.ValidatorType));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(ValidationPipelineBehavior <,>));

            _ = services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title   = "My API",
                    Version = "v1"
                });
                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme {
                    In          = ParameterLocation.Header,
                    Description = "Please insert JWT with Bearer into field",
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.ApiKey
                });
                c.AddSecurityRequirement(new OpenApiSecurityRequirement {
                    {
                        new OpenApiSecurityScheme {
                            Reference = new OpenApiReference {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        Array.Empty <string>()
                    }
                });
            });
        }