Rename WebApi project to Vegasco.Server.Api
All checks were successful
continuous-integration/drone/push Build is passing

And update all references including comments etc.
This commit is contained in:
2025-06-12 18:22:37 +02:00
parent 9d71c86474
commit a1999bfe41
71 changed files with 177 additions and 224 deletions

View File

@@ -1,6 +1,6 @@
using FluentValidation;
namespace Vegasco.WebApi.Authentication;
namespace Vegasco.Server.Api.Authentication;
public class JwtOptions
{

View File

@@ -2,7 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
namespace Vegasco.WebApi.Authentication;
namespace Vegasco.Server.Api.Authentication;
public sealed class UserAccessor
{

View File

@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Users;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Users;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public class Car
{

View File

@@ -1,6 +1,6 @@
using StronglyTypedIds;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
[StronglyTypedId]
public partial struct CarId;

View File

@@ -1,11 +1,11 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Authentication;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.WebApi.Users;
using Vegasco.Server.Api.Authentication;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
using Vegasco.Server.Api.Users;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class CreateCar
{

View File

@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class DeleteCar
{

View File

@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class GetCar
{

View File

@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class GetCars
{

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Authentication;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Authentication;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class UpdateCar
{

View File

@@ -1,4 +1,4 @@
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public static class Constants
{

View File

@@ -2,18 +2,19 @@
using FluentValidation;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Options;
using Vegasco.WebApi.Authentication;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Authentication;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public static class DependencyInjectionExtensions
{
/// <summary>
/// Adds all the WebApi related services to the Dependency Injection container.
/// Adds all the Api related services to the Dependency Injection container.
/// </summary>
/// <param name="builder"></param>
public static void AddWebApiServices(this IHostApplicationBuilder builder)
public static void AddApiServices(this IHostApplicationBuilder builder)
{
builder.Services
.AddMiscellaneousServices()
@@ -30,7 +31,7 @@ public static class DependencyInjectionExtensions
services.AddValidatorsFromAssemblies(
[
typeof(IWebApiMarker).Assembly
typeof(IApiMarker).Assembly
], ServiceLifetime.Singleton);
services.AddHealthChecks();
@@ -125,7 +126,7 @@ public static class DependencyInjectionExtensions
private static IHostApplicationBuilder AddDbContext(this IHostApplicationBuilder builder)
{
builder.AddNpgsqlDbContext<ApplicationDbContext>(Server.AppHost.Shared.Constants.Database.Name);
builder.AddNpgsqlDbContext<ApplicationDbContext>(AppHost.Shared.Constants.Database.Name);
return builder;
}
}

View File

@@ -2,7 +2,7 @@
using FluentValidation.Results;
using Microsoft.Extensions.Options;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public class FluentValidationOptions<TOptions> : IValidateOptions<TOptions>
where TOptions : class

View File

@@ -0,0 +1,3 @@
namespace Vegasco.Server.Api.Common;
public interface IApiMarker;

View File

@@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Localization;
using System.Globalization;
using Vegasco.WebApi.Endpoints;
using Vegasco.Server.Api.Endpoints;
using Vegasco.Server.ServiceDefaults;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
internal static class StartupExtensions
{
@@ -12,7 +13,7 @@ internal static class StartupExtensions
builder.Configuration.AddEnvironmentVariables("Vegasco_");
builder.AddWebApiServices();
builder.AddApiServices();
WebApplication app = builder.Build();
return app;

View File

@@ -2,7 +2,7 @@
using FluentValidation.Results;
using Microsoft.Extensions.Options;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public static class ValidatorExtensions
{
@@ -38,7 +38,7 @@ public static class ValidatorExtensions
{
if (!combinedErrors.TryGetValue(error.PropertyName, out HashSet<string>? value))
{
value = ([error.ErrorMessage]);
value = [error.ErrorMessage];
combinedErrors[error.PropertyName] = value;
continue;
}

View File

@@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public class Consumption
{

View File

@@ -1,6 +1,6 @@
using StronglyTypedIds;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
[StronglyTypedId]

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class CreateConsumption
{

View File

@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class DeleteConsumption
{

View File

@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class GetConsumption
{

View File

@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class GetConsumptions
{

View File

@@ -1,9 +1,9 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class UpdateConsumption
{

View File

@@ -1,12 +1,11 @@
using Asp.Versioning.Builder;
using Asp.Versioning.Conventions;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Info;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Info;
namespace Vegasco.WebApi.Endpoints;
namespace Vegasco.Server.Api.Endpoints;
public static class EndpointExtensions
{

View File

@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http.HttpResults;
namespace Vegasco.WebApi.Info;
namespace Vegasco.Server.Api.Info;
public class GetServerInfo
{

View File

@@ -1,10 +1,10 @@
using Microsoft.EntityFrameworkCore;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Users;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Users;
namespace Vegasco.WebApi.Persistence;
namespace Vegasco.Server.Api.Persistence;
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
{
@@ -17,6 +17,6 @@ public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfigurationsFromAssembly(typeof(IWebApiMarker).Assembly);
modelBuilder.ApplyConfigurationsFromAssembly(typeof(IApiMarker).Assembly);
}
}

View File

@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
namespace Vegasco.WebApi.Persistence;
namespace Vegasco.Server.Api.Persistence;
public class ApplyMigrationsService(ILogger<ApplyMigrationsService> logger, IServiceScopeFactory scopeFactory)
: IHostedService

View File

@@ -5,11 +5,12 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
#nullable disable
namespace Vegasco.WebApi.Persistence.Migrations
namespace Vegasco.Server.Api.Persistence.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240818105918_Initial")]
@@ -25,7 +26,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -46,7 +47,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Cars");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -73,7 +74,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
@@ -83,9 +84,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Users");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.HasOne("Vegasco.WebApi.Users.User", "User")
b.HasOne("Vegasco.Server.Api.Users.User", "User")
.WithMany("Cars")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@@ -94,9 +95,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.HasOne("Vegasco.WebApi.Cars.Car", "Car")
b.HasOne("Vegasco.Server.Api.Cars.Car", "Car")
.WithMany("Consumptions")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
@@ -105,12 +106,12 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("Car");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Navigation("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Navigation("Cars");
});

View File

@@ -1,9 +1,8 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Vegasco.WebApi.Persistence.Migrations
namespace Vegasco.Server.Api.Persistence.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration

View File

@@ -4,11 +4,12 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
#nullable disable
namespace Vegasco.WebApi.Persistence.Migrations
namespace Vegasco.Server.Api.Persistence.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
@@ -22,7 +23,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -43,7 +44,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Cars");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -70,7 +71,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
@@ -80,9 +81,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Users");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.HasOne("Vegasco.WebApi.Users.User", "User")
b.HasOne("Vegasco.Server.Api.Users.User", "User")
.WithMany("Cars")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@@ -91,9 +92,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.HasOne("Vegasco.WebApi.Cars.Car", "Car")
b.HasOne("Vegasco.Server.Api.Cars.Car", "Car")
.WithMany("Consumptions")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
@@ -102,12 +103,12 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("Car");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Navigation("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Navigation("Cars");
});

View File

@@ -1,4 +1,4 @@
using Vegasco.WebApi.Common;
using Vegasco.Server.Api.Common;
WebApplication.CreateBuilder(args)
.ConfigureServices()

View File

@@ -1,6 +1,6 @@
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace Vegasco.WebApi.Users;
namespace Vegasco.Server.Api.Users;
public class User
{

View File

@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Vegasco.WebApi.Users;
namespace Vegasco.Server.Api.Users;
public class UserTableConfiguration : IEntityTypeConfiguration<User>
{

View File

@@ -7,7 +7,7 @@
<UserSecretsId>4bf893d3-0c16-41ec-8b46-2768d841215d</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
<RootNamespace>Vegasco.WebApi</RootNamespace>
<RootNamespace>Vegasco.Server.Api</RootNamespace>
</PropertyGroup>
<ItemGroup>

View File

@@ -4,7 +4,7 @@ public static class Constants
{
public static class Projects
{
public const string WebApiName = "webapi";
public const string Api = "Vegasco_Server_Api";
}
public static class Database

View File

@@ -7,7 +7,7 @@ IResourceBuilder<PostgresDatabaseResource> postgres = builder.AddPostgres(Consta
.AddDatabase(Constants.Database.Name);
builder
.AddProject<Projects.WebApi>(Constants.Projects.WebApiName)
.AddProject<Projects.Vegasco_Server_Api>(Constants.Projects.Api)
.WithReference(postgres)
.WaitFor(postgres);

View File

@@ -21,7 +21,7 @@
<ItemGroup>
<ProjectReference Include="..\Vegasco.Server.AppHost.Shared\Vegasco.Server.AppHost.Shared.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\WebApi\WebApi.csproj" />
<ProjectReference Include="..\Vegasco.Server.Api\Vegasco.Server.Api.csproj" />
</ItemGroup>
</Project>

View File

@@ -2,13 +2,13 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
namespace Microsoft.Extensions.Hosting;
namespace Vegasco.Server.ServiceDefaults;
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.

View File

@@ -1,3 +0,0 @@
namespace Vegasco.WebApi.Common;
public interface IWebApiMarker;