@@ -27,10 +27,7 @@ public static async Task Main(string[] args)
2727 {
2828 var builder = WebApplication . CreateBuilder ( args ) ;
2929 builder . AddServiceDefaults ( ) ;
30-
31- //Log
32- //TODO: Begin to log usefull things
33- //builder.Host.UseSerilog((context, configuration) => configuration.ReadFrom.Configuration(context.Configuration));
30+ builder . AddServiceApiDefaults ( ) ;
3431
3532 //Options
3633 var authOptions = new AuthServerOptions ( ) ;
@@ -40,22 +37,12 @@ public static async Task Main(string[] args)
4037 var swaggerUIOptions = new SwaggerUIOptions ( ) ;
4138 builder . Configuration . GetSection ( SwaggerUIOptions . Position ) . Bind ( swaggerUIOptions ) ;
4239
43- //Auth server and JWT (no need, no auth)
44- //builder.Services.AddAuthServerAndJwt(authOptions);
45-
46- ////Default httpclient - Aspire now
47- //builder.Services.ConfigureHttpClientDefaults(http =>
48- //{
49- // http.AddStandardResilienceHandler();
50- //});
51-
5240 //DB
5341 builder . Services . AddDbContextFactory < AccountingDbContext > (
5442 options => options . UseNpgsql ( builder . Configuration . GetConnectionString ( "AccountingContext" ) ) , ServiceLifetime . Scoped ) ;
5543
5644 Dapper . DefaultTypeMap . MatchNamesWithUnderscores = true ;
5745
58- //TODO: remove useless parts (only pub/sub)
5946 //MessageBroker with masstransit + outbox
6047 builder . Services . AddMassTransit ( config =>
6148 {
@@ -90,28 +77,9 @@ public static async Task Main(string[] args)
9077 } ) ;
9178
9279 //Add all consumers
93- //config.AddConsumers(Assembly.GetExecutingAssembly());
94-
95- //Add commands clients
96-
80+ config . AddConsumers ( Assembly . GetExecutingAssembly ( ) ) ;
9781 } ) ;
9882
99-
100- //Api versioning
101- builder . Services . AddApiVersionAndExplorer ( ) ;
102-
103- //TODO: Cors
104- builder . Services . AddCustomCors ( ) ;
105-
106- ////Tracing and metrics - Aspire now
107- //builder.Logging.AddOpenTelemetry(logging =>
108- //{
109- // logging.IncludeFormattedMessage = true;
110- // logging.IncludeScopes = true;
111- //});
112-
113- //builder.Services.AddTracingAndMetrics();
114-
11583 //Swagger config
11684 var xmlPath = Path . Combine ( AppContext . BaseDirectory ,
11785 $ "{ Assembly . GetExecutingAssembly ( ) . GetName ( ) . Name } .xml") ;
@@ -131,22 +99,6 @@ public static async Task Main(string[] args)
13199 builder . Services . AddScoped < ICurrentUser , CurrentUser > ( ) ;
132100 builder . Services . AddTransient < ProblemDetailsFactory , CustomProblemDetailsFactory > ( ) ;
133101
134- //Strandard API things
135- builder . Services . AddControllers ( o =>
136- {
137- o . Filters . Add ( new ProducesAttribute ( "application/json" ) ) ;
138- } ) . AddJsonOptions ( options =>
139- options . JsonSerializerOptions . Converters . Add ( new JsonStringEnumConverter ( ) ) ) ;
140-
141- builder . Services . AddHttpContextAccessor ( ) ;
142- builder . Services . AddEndpointsApiExplorer ( ) ;
143-
144- //Route config
145- builder . Services . Configure < RouteOptions > ( options =>
146- {
147- options . LowercaseUrls = true ;
148- } ) ;
149-
150102 //Build the app
151103 var app = builder . Build ( ) ;
152104
@@ -186,10 +138,6 @@ public static async Task Main(string[] args)
186138 subApp => subApp . UseMiddleware < UserInHeaderMiddleware > ( )
187139 ) ;
188140
189- //app.UseHttpsRedirection();
190- //app.UseAuthentication();
191- //app.UseAuthorization();
192-
193141 app . MapControllers ( ) ;
194142 app . Run ( ) ;
195143 }
0 commit comments