// Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Container container) { SetConfig(new HostConfig { //DebugMode = false, DebugMode = true, AdminAuthSecret = "secret", }); // Register Database Connection, see: https://github.com/ServiceStack/ServiceStack.OrmLite#usage container.AddSingleton <IDbConnectionFactory>(c => new OrmLiteConnectionFactory(MapProjectPath("~/northwind.sqlite"), SqliteDialect.Provider)); // For TodosService Plugins.Add(new AutoQueryDataFeature()); // For NorthwindAuto + Bookings Plugins.Add(new AutoQueryFeature { MaxLimit = 100, GenerateCrudServices = new GenerateCrudServices { } }); ConfigurePlugin <UiFeature>(feature => { Console.WriteLine("ConfigurePlugin<UiFeature>..."); //feature.Module.EnableHttpCaching = true; feature.Module.Configure((appHost, module) => { module.VirtualFiles = appHost.VirtualFiles; module.DirPath = module.DirPath.Replace("/modules", ""); }); feature.Handlers.Cast <SharedFolder>().Each(x => x.SharedDir = x.SharedDir.Replace("/modules", "")); }); // Not needed in `dotnet watch` and in /wwwroot/modules/ui which can use _framework/aspnetcore-browser-refresh.js" Plugins.AddIfDebug(new HotReloadFeature { VirtualFiles = VirtualFiles, DefaultPattern = "*.html;*.js;*.css" }); //Plugins.Add(new PostmanFeature()); }
// Configure your AppHost with the necessary configuration and dependencies your App needs public override void Configure(Container container) { // JsConfig.Init(new ServiceStack.Text.Config { // IncludeNullValues = true, // TextCase = TextCase.PascalCase // }); SetConfig(new HostConfig { //DebugMode = false, DebugMode = true, AdminAuthSecret = "secret", }); var memFs = GetVirtualFileSource <MemoryVirtualFiles>(); var files = VirtualFiles.GetDirectory("custom").GetAllFiles(); files.Each(file => memFs.WriteFile($"locode/{file.Name}", file)); GlobalRequestFilters.Add((req, res, dto) => { files.Each(file => memFs.WriteFile($"locode/{file.Name}", file)); }); ConfigurePlugin <UiFeature>(feature => { Console.WriteLine(@"ConfigurePlugin<UiFeature>..."); feature.HtmlModules.Add(new("/modules/forms", "/forms")); feature.Module.Configure((appHost, module) => { module.VirtualFiles = appHost.VirtualFiles; module.DirPath = module.DirPath.Replace("/modules", ""); }); feature.Handlers.Cast <SharedFolder>().Each(x => x.SharedDir = x.SharedDir.Replace("/modules", "")); }); // Not needed in `dotnet watch` and in /wwwroot/modules/ui which can use _framework/aspnetcore-browser-refresh.js" Plugins.AddIfDebug(new HotReloadFeature { VirtualFiles = VirtualFiles, DefaultPattern = "*.html;*.js;*.css" }); //Plugins.Add(new PostmanFeature()); var uploadVfs = new FileSystemVirtualFiles(TalentBlazorWwwRootDir); var appDataVfs = new FileSystemVirtualFiles(TalentBlazorAppDataDir); Plugins.Add(new FilesUploadFeature( new UploadLocation("profiles", uploadVfs, allowExtensions: FileExt.WebImages, resolvePath: ctx => $"/profiles/{ctx.FileName}"), new UploadLocation("game_items", appDataVfs, allowExtensions: FileExt.WebImages), new UploadLocation("files", GetVirtualFileSource <FileSystemVirtualFiles>(), resolvePath: ctx => $"/files/{ctx.FileName}"), new UploadLocation("users", uploadVfs, allowExtensions: FileExt.WebImages, resolvePath: ctx => $"/profiles/users/{ctx.UserAuthId}.{ctx.FileExtension}"), new UploadLocation("applications", appDataVfs, maxFileCount: 3, maxFileBytes: 10_000_000, resolvePath: ctx => ctx.GetLocationPath((ctx.Dto is CreateJobApplication create ? $"job/{create.JobId}" : $"app/{ctx.Dto.GetId()}") + $"/{ctx.DateSegment}/{ctx.FileName}"), readAccessRole: RoleNames.AllowAnon, writeAccessRole: RoleNames.AllowAnon) )); Metadata.ForceInclude = new() { typeof(GetAccessToken) }; Plugins.Add(new ServiceStack.Api.OpenApi.OpenApiFeature()); }