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.ServiceModel/Hello.cs b/MyApp.ServiceModel/Hello.cs
index ac63beb..b0f2139 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 c913e11..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 3403b7c..6acf19c 100644
--- a/MyApp/Configure.Db.cs
+++ b/MyApp/Configure.Db.cs
@@ -13,9 +13,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 e0502b7..a23f7a6 100644
--- a/MyApp/Configure.Markdown.cs
+++ b/MyApp/Configure.Markdown.cs
@@ -15,9 +15,11 @@ public void Configure(IWebHostBuilder builder) => builder
services.AddSingleton();
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 32292f9..00ee9a0 100644
--- a/MyApp/MyApp.csproj
+++ b/MyApp/MyApp.csproj
@@ -25,6 +25,7 @@
+
diff --git a/MyApp/Program.cs b/MyApp/Program.cs
index 5f77614..550f3ff 100644
--- a/MyApp/Program.cs
+++ b/MyApp/Program.cs
@@ -9,6 +9,7 @@
using MyApp.Components;
using MyApp.Data;
using MyApp.Components.Account;
+using MyApp.ServiceInterface;
var builder = WebApplication.CreateBuilder(args);
@@ -57,12 +58,25 @@
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.
if (app.Environment.IsDevelopment())
{
app.UseMigrationsEndPoint();
+ app.UseSwagger();
+ app.UseSwaggerUI();
}
else
{
@@ -81,7 +95,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