Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHttpContextAccessor();
            services.AddMemoryCache();
            // Enable IHttpClientFactory
            services.AddHttpClient();
            services.ActAsServer(Configuration, options =>
            {
                options.EnableDatabaseOptions = true;
                options.EnableSerilog         = true;
                options.EnableServiceMonitor  = true;
                options.EnableBuiltInCors     = true;
                options.ServerName            = "Saturn";
            });

            // Changed from 0.9.0: We need to separate DatabaseOptions
            // This is very useful for reusability
            services
            .AddDatabaseOptions(Configuration)
            .RegisterIdentityRepos()
            .RegisterPortalRepos()
            .RegisterSaturnServerRepos();

            // Changed from 0.9.0: AddLetPortal is just providing Builder for combining all Features
            services
            .AddLetPortal(Configuration)
            .AddIdentity()
            .AddJwtValidator(
                hubSegments: new List <string>
            {
                "/chathub",
                "/videohub"
            })
            .AddChat()
            .AddPortalService(options =>
            {
                options.EnableFileServer = true;
            });

            services
            .AddControllers()
            .AddApplicationPart(typeof(AppsController).Assembly)
            .AddApplicationPart(typeof(AccountsController).Assembly)
            .AddApplicationPart(typeof(ConfigurationController).Assembly)
            .AddNewtonsoftJson(options =>
            {
                // Important note: we still use Newtonsoft instead of .NET JSON because they still don't support Timezone
                options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
            });

            // Call SignalR when Chat is used
            services.AddSignalR();

            // Enable Grpc for Microservices
            services.AddGrpc(options =>
            {
                options.EnableDetailedErrors  = true;
                options.MaxReceiveMessageSize = 1 * 1024 * 1024 * 5; // 5 MB
                options.MaxSendMessageSize    = 1 * 1024 * 1024 * 5; // 5 MB
            });

            services.AddOpenApiDocument();
        }