Skip to content

Commit

Permalink
Merge pull request #41 from AmielCyber/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AmielCyber authored Jul 12, 2023
2 parents 4e7fe55 + a2ee155 commit 1c3ffc5
Show file tree
Hide file tree
Showing 15 changed files with 403 additions and 362 deletions.
37 changes: 15 additions & 22 deletions PetSearch.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
// Add services to the container.
builder.Services.AddControllers();
// Set up Database connection.
// Set up for EF service
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ??
throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
// Set up for EF service
var serverVersion = new MySqlServerVersion(new Version(8, 0, 31));
builder.Services.AddDbContext<PetSearchContext>(
// Specify the database provider
options => options.UseMySql(connectionString, serverVersion));
// Set up Swagger
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
Expand All @@ -32,6 +33,7 @@
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Pet Search API", Version = "v1" });
});

// Configure CORS for local development with React.
builder.Services.AddCors(options =>
{
options.AddPolicy(name: myAllowSpecificOrigins,
Expand All @@ -42,6 +44,7 @@
});
// Add Strongly type configuration.
builder.Services.Configure<PetFinderConfiguration>(builder.Configuration.GetSection("PetFinder"));
// Add HTTPClient to DI container.
builder.Services.AddHttpClient<IPetFinderClient, PetFinderClient>(client =>
{
client.BaseAddress = new Uri(petFinderUrl);
Expand All @@ -60,32 +63,22 @@
using var context = scope.ServiceProvider.GetRequiredService<PetSearchContext>();
context.Database.EnsureCreated();
}

if (app.Environment.IsDevelopment())
{
}

// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
// Expose swagger.
app.UseSwagger();
app.UseSwaggerUI(config => { config.ConfigObject.AdditionalItems.Add("persistAuthorization", "true"); });
// Global error handling middleware.
app.UseMiddleware<ExceptionMiddleware>();
// Set up middleware to serve static content (React)
app.UseDefaultFiles();
app.UseStaticFiles();
// Move default middleware below the client-app middleware to short-circuit client-app routes.
app.UseRouting();
if (app.Environment.IsDevelopment())
app.UseHttpsRedirection(); // Configure the HTTP request pipeline.
app.UseSwagger(); // Expose swagger.
app.UseSwaggerUI(); // Show swagger UI @ /swagger/index.html
app.UseMiddleware<ExceptionMiddleware>(); // Global error handling middleware.
app.UseDefaultFiles(); // Serve default file from wwwroot w/o requesting URL file name.
app.UseStaticFiles(); // Set up middleware to serve static content (React).
app.UseRouting(); // Move default middleware below the client-app middleware to short-circuit client-app routes.
if (app.Environment.IsDevelopment()) // Use cors configuration to develop with our client app.
{
// Use cors configuration to develop with our client app.
app.UseCors(myAllowSpecificOrigins);
}

app.UseAuthorization();
app.MapControllers();
// Tell our server how to handle paths that it doesnt know of but React does.
app.MapFallbackToController("Index", "Fallback");
app.MapFallbackToController("Index",
"Fallback"); // Tell our server how to handle paths that it doesnt know of but React does.
// End up setting up middleware to the pipeline.

app.Run();

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions PetSearch.API/wwwroot/assets/PetSearchPage-f7f4102a.css
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
._imageContainer_pbgyy_1 {
width: 300px;
height: 300px;
overflow: hidden;
display: flex;
justify-content: center
}

._imageContainer_pbgyy_1 img {
object-fit: cover
}
._imageContainer_pbgyy_1{width:300px;height:300px;overflow:hidden;display:flex;justify-content:center}._imageContainer_pbgyy_1 img{object-fit:cover}
Loading

0 comments on commit 1c3ffc5

Please sign in to comment.