diff --git a/MyApp.Client/Pages/Auth.razor b/MyApp.Client/Pages/Auth.razor
deleted file mode 100644
index ca9163b..0000000
--- a/MyApp.Client/Pages/Auth.razor
+++ /dev/null
@@ -1,14 +0,0 @@
-@page "/auth"
-
-@using Microsoft.AspNetCore.Authorization
-
-@attribute [Authorize]
-@rendermode InteractiveAuto
-
-Auth
-
-
You are authenticated
-
-
- Hello @context.User.Identity?.Name!
-
diff --git a/MyApp.ServiceInterface/EmailServices.cs b/MyApp.ServiceInterface/EmailServices.cs
index 5bc52b2..5e3974a 100644
--- a/MyApp.ServiceInterface/EmailServices.cs
+++ b/MyApp.ServiceInterface/EmailServices.cs
@@ -48,32 +48,24 @@ public class SmtpConfig
///
/// Uses a configured SMTP client to send emails
///
-public class EmailServices : Service
+public class EmailServices(SmtpConfig config, ILogger log)
+ // TODO: Uncomment to enable sending emails with SMTP
+ // : Service
{
- public EmailServices(SmtpConfig config, ILogger log)
- {
- Config = config;
- Log = log;
- }
-
- public SmtpConfig Config { get; }
- public ILogger Log { get; }
-
- /* Uncomment to enable sending emails with SMTP
public object Any(SendEmail request)
{
- Log.LogInformation("Sending email to {Email} with subject {Subject}", request.To, request.Subject);
+ log.LogInformation("Sending email to {Email} with subject {Subject}", request.To, request.Subject);
- using var client = new SmtpClient(Config.Host, Config.Port);
- client.Credentials = new System.Net.NetworkCredential(Config.Username, Config.Password);
+ using var client = new SmtpClient(config.Host, config.Port);
+ client.Credentials = new System.Net.NetworkCredential(config.Username, config.Password);
client.EnableSsl = true;
// If DevToEmail is set, send all emails to that address instead
- var emailTo = Config.DevToEmail != null
- ? new MailAddress(Config.DevToEmail)
+ var emailTo = config.DevToEmail != null
+ ? new MailAddress(config.DevToEmail)
: new MailAddress(request.To, request.ToName);
- var emailFrom = new MailAddress(Config.FromEmail, Config.FromName);
+ var emailFrom = new MailAddress(config.FromEmail, config.FromName);
var msg = new MailMessage(emailFrom, emailTo)
{
@@ -82,14 +74,13 @@ public object Any(SendEmail request)
IsBodyHtml = request.BodyHtml != null,
};
- if (Config.Bcc != null)
+ if (config.Bcc != null)
{
- msg.Bcc.Add(new MailAddress(Config.Bcc));
+ msg.Bcc.Add(new MailAddress(config.Bcc));
}
client.Send(msg);
return new EmptyResponse();
}
- */
}
diff --git a/MyApp.ServiceInterface/TodosServices.cs b/MyApp.ServiceInterface/TodosServices.cs
index 5ecd866..fed7b88 100644
--- a/MyApp.ServiceInterface/TodosServices.cs
+++ b/MyApp.ServiceInterface/TodosServices.cs
@@ -5,10 +5,8 @@
namespace MyApp.ServiceInterface;
-public class TodosServices : Service
+public class TodosServices(IAutoQueryData AutoQuery) : Service
{
- public IAutoQueryData AutoQuery { get; set; }
-
static readonly PocoDataSource Todos = PocoDataSource.Create(new Todo[]
{
new () { Id = 1, Text = "Learn" },
diff --git a/MyApp.ServiceModel/Hello.cs b/MyApp.ServiceModel/Hello.cs
index b52b306..1a698bc 100644
--- a/MyApp.ServiceModel/Hello.cs
+++ b/MyApp.ServiceModel/Hello.cs
@@ -4,7 +4,7 @@ namespace MyApp.ServiceModel;
[Route("/hello")]
[Route("/hello/{Name}")]
-public class Hello : IReturn
+public class Hello : IGet, IReturn
{
public string? Name { get; set; }
}
diff --git a/MyApp/Configure.Auth.cs b/MyApp/Configure.Auth.cs
index 14c47a5..229a79b 100644
--- a/MyApp/Configure.Auth.cs
+++ b/MyApp/Configure.Auth.cs
@@ -8,9 +8,9 @@ namespace MyApp;
public class ConfigureAuth : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
- .ConfigureAppHost(appHost =>
+ .ConfigureServices((context, services) =>
{
- appHost.Plugins.Add(new AuthFeature(IdentityAuth.For(options => {
+ services.AddPlugin(new AuthFeature(IdentityAuth.For(options => {
options.EnableCredentialsAuth = true;
options.SessionFactory = () => new CustomUserSession();
})));
diff --git a/MyApp/Configure.AutoQuery.cs b/MyApp/Configure.AutoQuery.cs
index e3837a8..11261ca 100644
--- a/MyApp/Configure.AutoQuery.cs
+++ b/MyApp/Configure.AutoQuery.cs
@@ -11,20 +11,17 @@ public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices(services => {
// Enable Audit History
services.AddSingleton(c =>
- new OrmLiteCrudEvents(c.Resolve()));
- })
- .ConfigureAppHost(appHost => {
-
+ new OrmLiteCrudEvents(c.GetRequiredService()));
// For TodosService
- appHost.Plugins.Add(new AutoQueryDataFeature());
-
+ services.AddPlugin(new AutoQueryDataFeature());
// For Bookings https://docs.servicestack.net/autoquery-crud-bookings
- appHost.Plugins.Add(new AutoQueryFeature
+ services.AddPlugin(new AutoQueryFeature
{
MaxLimit = 1000,
//IncludeTotal = true,
});
-
+ })
+ .ConfigureAppHost(appHost => {
appHost.Resolve().InitSchema();
});
}
\ No newline at end of file
diff --git a/MyApp/Configure.Db.cs b/MyApp/Configure.Db.cs
index 3130aba..a00bd98 100644
--- a/MyApp/Configure.Db.cs
+++ b/MyApp/Configure.Db.cs
@@ -17,9 +17,8 @@ public void Configure(IWebHostBuilder builder) => builder
context.Configuration.GetConnectionString("DefaultConnection")
?? ":memory:",
SqliteDialect.Provider));
- })
- .ConfigureAppHost(appHost => {
+
// Enable built-in Database Admin UI at /admin-ui/database
- appHost.Plugins.Add(new AdminDatabaseFeature());
+ services.AddPlugin(new AdminDatabaseFeature());
});
}
diff --git a/MyApp/Configure.Markdown.cs b/MyApp/Configure.Markdown.cs
index 7f13c96..b4353f7 100644
--- a/MyApp/Configure.Markdown.cs
+++ b/MyApp/Configure.Markdown.cs
@@ -15,9 +15,11 @@ public void Configure(IWebHostBuilder builder) => builder
services.AddSingleton(AppConfig.Instance);
services.AddSingleton();
services.AddSingleton();
+
+ // Plugins
+ services.AddPlugin(new CleanUrlsFeature());
})
.ConfigureAppHost(
- appHost => appHost.Plugins.Add(new CleanUrlsFeature()),
afterPluginsLoaded: appHost =>
{
var pages = appHost.Resolve();
diff --git a/MyApp/MyApp.csproj b/MyApp/MyApp.csproj
index a813228..3657326 100644
--- a/MyApp/MyApp.csproj
+++ b/MyApp/MyApp.csproj
@@ -30,6 +30,7 @@
+
diff --git a/MyApp/Program.cs b/MyApp/Program.cs
index 3f3477c..f85e65c 100644
--- a/MyApp/Program.cs
+++ b/MyApp/Program.cs
@@ -8,6 +8,7 @@
using MyApp.Data;
using ServiceStack.Blazor;
using System.Net;
+using MyApp.ServiceInterface;
var builder = WebApplication.CreateBuilder(args);
@@ -57,6 +58,17 @@
services.AddBlazorServerIdentityApiClient(baseUrl);
services.AddLocalStorage();
+services.AddEndpointsApiExplorer();
+services.AddSwaggerGen();
+
+// Register all services
+services.AddServiceStack(typeof(MyServices).Assembly, c => {
+ c.AddSwagger(o => {
+ //o.AddJwtBearer();
+ o.AddBasicAuth();
+ });
+});
+
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -64,6 +76,8 @@
{
app.UseWebAssemblyDebugging();
app.UseMigrationsEndPoint();
+ app.UseSwagger();
+ app.UseSwaggerUI();
}
else
{
@@ -85,7 +99,10 @@
// Add additional endpoints required by the Identity /Account Razor components.
app.MapAdditionalIdentityEndpoints();
-app.UseServiceStack(new AppHost());
+app.UseServiceStack(new AppHost(), options =>
+{
+ options.MapEndpoints();
+});
BlazorConfig.Set(new()
{
diff --git a/NuGet.Config b/NuGet.Config
new file mode 100644
index 0000000..4de72bf
--- /dev/null
+++ b/NuGet.Config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file