Added scalar api reference
Successful local run
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MimeKit;
|
||||
using Scalar.AspNetCore;
|
||||
using SmtpClient = MailKit.Net.Smtp.SmtpClient;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var allowedOrigins = builder.Configuration.GetSection("CorsSettings:AllowedOrigins").Get<string[]>() ?? Array.Empty<string>();
|
||||
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
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.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 };
|
||||
message.Body = bodyBuilder.ToMessageBody();
|
||||
@@ -60,4 +62,7 @@ app.MapPost("/api/send-email", async ([FromBody] EmailRequest request, IConfigur
|
||||
}
|
||||
});
|
||||
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference();
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user