Added scalar api reference
Successful local run
This commit is contained in:
@@ -1 +1 @@
|
|||||||
public sealed record EmailRequest(string HtmlBody, string? From, string? To);
|
public sealed record EmailRequest(string HtmlBody, string? From, string? To, string? Subject);
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
<PackageReference Include="MailKit" Version="4.17.0" />
|
<PackageReference Include="MailKit" Version="4.17.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.9" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.9" />
|
||||||
<PackageReference Include="Microsoft.OpenApi" Version="2.10.0" />
|
<PackageReference Include="Microsoft.OpenApi" Version="2.10.0" />
|
||||||
|
<PackageReference Include="Scalar.AspNetCore" Version="2.16.11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
|
using Scalar.AspNetCore;
|
||||||
using SmtpClient = MailKit.Net.Smtp.SmtpClient;
|
using SmtpClient = MailKit.Net.Smtp.SmtpClient;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
var allowedOrigins = builder.Configuration.GetSection("CorsSettings:AllowedOrigins").Get<string[]>() ?? Array.Empty<string>();
|
var allowedOrigins = builder.Configuration.GetSection("CorsSettings:AllowedOrigins").Get<string[]>() ?? Array.Empty<string>();
|
||||||
|
|
||||||
|
builder.Services.AddOpenApi();
|
||||||
builder.Services.AddCors(options =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddPolicy("AllowStrictOrigins", policy =>
|
options.AddPolicy("AllowStrictOrigins", policy =>
|
||||||
@@ -34,7 +36,7 @@ app.MapPost("/api/send-email", async ([FromBody] EmailRequest request, IConfigur
|
|||||||
|
|
||||||
message.From.Add(MailboxAddress.Parse(fromAddress!));
|
message.From.Add(MailboxAddress.Parse(fromAddress!));
|
||||||
message.To.Add(MailboxAddress.Parse(toAddress!));
|
message.To.Add(MailboxAddress.Parse(toAddress!));
|
||||||
message.Subject = "New message from LiteCharms";
|
message.Subject = string.IsNullOrWhiteSpace(request.Subject) ? "New message from LiteCharms" : request.Subject;
|
||||||
|
|
||||||
var bodyBuilder = new BodyBuilder { HtmlBody = request.HtmlBody };
|
var bodyBuilder = new BodyBuilder { HtmlBody = request.HtmlBody };
|
||||||
message.Body = bodyBuilder.ToMessageBody();
|
message.Body = bodyBuilder.ToMessageBody();
|
||||||
@@ -60,4 +62,7 @@ app.MapPost("/api/send-email", async ([FromBody] EmailRequest request, IConfigur
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.MapOpenApi();
|
||||||
|
app.MapScalarApiReference();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"Port": 465,
|
"Port": 465,
|
||||||
"UseSsl": true,
|
"UseSsl": true,
|
||||||
"Username": "contact@litecharms.co.za",
|
"Username": "contact@litecharms.co.za",
|
||||||
"Password": "YPPUzCl%TL$GD*x7f",
|
"Password": "wfnsoinfowin",
|
||||||
"DefaultFrom": "LiteCharms <contact@khongisa.co.za>",
|
"DefaultFrom": "LiteCharms <contact@khongisa.co.za>",
|
||||||
"DefaultTo": "contact@litecharms.co.za"
|
"DefaultTo": "contact@litecharms.co.za"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user