_template-service/Program.cs
adam 75381d62a7
Some checks failed
gitea.arg.rip/_template-service/pipeline/head There was a failure building this commit
can't transform without word boundary, apparently
2024-12-13 15:07:48 -05:00

53 lines
1.4 KiB
C#

using $REPO_NAME;
using $REPO_NAME.Components;
using $REPO_NAME.Models;
var conf = greyn.Deployment.Configurator<$REPO_NAME.Configuration>.Load();
Shared.DBConnectionString = conf.DBConnectionString;
Console.WriteLine(Shared.DBConnectionString);
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddAuthorization();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapGet("/hi", () => {
var db = new $REPO_NAME_DBContext();
var greetcount = db.Greets.FirstOrDefault();
if(greetcount == null)
{
greetcount = new GreetCounter();
db.Greets.Add(greetcount);
}
greetcount.Amount++;
db.SaveChanges();
return $"hello number {greetcount.Amount}";
}).WithName("hi").WithOpenApi();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();