Пример #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            services.AddNodeServices(options =>
            {
                if (CurrentEnvironment.IsDevelopment())
                {
                    options.LaunchWithDebugging = true;
                    options.DebuggingPort       = 9229;
                    options.ProjectPath         = "../Frontend/ClientApp";
                }
                else
                {
                    options.ProjectPath = "ClientApp/";
                }
            });

            services.AddSpaPrerenderer();
            services.AddSingleton(GetPrerenderContent());
            services
            .AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });


            var accountOptions = new AccountOptions(
                Configuration[Defaults.ORGANIZATION_ID],
                Configuration[Defaults.TECHNICAL_ACCOUNT_ID],
                Configuration[Defaults.CLIENT_ID],
                Configuration[Defaults.CLIENT_SECRET]);


            var securityKey = GetSecurityKey(Configuration[Defaults.CERTIFICATE_PATH]);
            var reactorApi  = new ReactorApi(accountOptions, securityKey);


            services
            .AddSingleton(reactorApi)
            .AddSingleton <ReactorService>();


            services.AddCors(options =>
            {
                options.AddPolicy(Defaults.ALL_CORS_POLICY,
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });
        }
Пример #2
0
 public PreRenderController(ReactorApi reactorApi, PrerenderContent prerenderContent)
 {
     _prerenderContent = prerenderContent;
     _reactorApi       = reactorApi;
 }
 public ReactorService(ReactorApi reactorApi, ILoggerFactory loggerFactory)
 {
     _reactorApi = reactorApi;
     _logger     = loggerFactory.CreateLogger <ReactorService>();
 }