| 
									
										
										
										
											2025-07-01 11:10:28 -03:00
										 |  |  | // Importamos los namespaces necesarios | 
					
						
							|  |  |  | using Mercados.Infrastructure; | 
					
						
							|  |  |  | using Mercados.Infrastructure.Persistence; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-01 10:46:13 -03:00
										 |  |  | var builder = WebApplication.CreateBuilder(args); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-01 11:10:28 -03:00
										 |  |  | // 1. Registramos nuestra fábrica de conexiones como un Singleton. | 
					
						
							|  |  |  | // Solo se creará una instancia que leerá la configuration una vez. | 
					
						
							|  |  |  | builder.Services.AddSingleton<IDbConnectionFactory, SqlConnectionFactory>(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-01 10:46:13 -03:00
										 |  |  | // Add services to the container. | 
					
						
							| 
									
										
										
										
											2025-07-01 11:10:28 -03:00
										 |  |  | builder.Services.AddControllers(); | 
					
						
							|  |  |  | builder.Services.AddEndpointsApiExplorer(); | 
					
						
							|  |  |  | builder.Services.AddSwaggerGen(); | 
					
						
							| 
									
										
										
										
											2025-07-01 10:46:13 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var app = builder.Build(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Configure the HTTP request pipeline. | 
					
						
							|  |  |  | if (app.Environment.IsDevelopment()) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-07-01 11:10:28 -03:00
										 |  |  |     app.UseSwagger(); | 
					
						
							|  |  |  |     app.UseSwaggerUI(); | 
					
						
							| 
									
										
										
										
											2025-07-01 10:46:13 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.UseHttpsRedirection(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-01 11:10:28 -03:00
										 |  |  | app.UseAuthorization(); | 
					
						
							| 
									
										
										
										
											2025-07-01 10:46:13 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-01 11:10:28 -03:00
										 |  |  | app.MapControllers(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.Run(); |