added rate limiting middleware and configured it. added quotes data in json format. added method to seeder to seed database with quote data.

This commit is contained in:
StevanFreeborn
2022-06-21 23:24:56 -05:00
parent b452e8db0b
commit 9b6365b88b
8 changed files with 4207 additions and 17 deletions
+5 -5
View File
@@ -24,7 +24,7 @@ namespace server.Controllers.v1
/// <response code="200">Returns the collection of episodes requested.</response>
/// <response code="400">Not a valid request.</response>
/// <response code="500">Failed to get episodes.</response>
/// <returns>A collection of episodes.</returns>
/// <returns>Returns a collection of episodes.</returns>
[MapToApiVersion("1.0")]
[HttpGet]
[ProducesResponseType(typeof(List<Episode>), StatusCodes.Status200OK)]
@@ -52,7 +52,7 @@ namespace server.Controllers.v1
/// <response code="400">Not a valid request.</response>
/// <response code="404">Unable to find an episode with the provided number.</response>
/// <response code="500">Failed to get episode.</response>
/// <returns>The episode requested.</returns>
/// <returns>Returns the episode requested.</returns>
[MapToApiVersion("1.0")]
[HttpGet("{number:int}")]
[ProducesResponseType(typeof(Episode), StatusCodes.Status200OK)]
@@ -65,9 +65,9 @@ namespace server.Controllers.v1
{
var episode = await _episodeRepository.GetEpisodeByNumberAsync(number);
if (episode == null) return Problem(detail: $"Could not find episode {number}", statusCode: 404);
return Ok(episode);
return episode == null ?
Problem(detail: $"Could not find episode {number}", statusCode: 404) :
Ok(episode);
}
catch (Exception e)
{
+16 -4
View File
@@ -17,6 +17,12 @@ namespace server.Controllers.v1
_seasonRepository = seasonRepository;
}
/// <summary>
/// Gets a collection of seasons.
/// </summary>
/// <response code="200">Returns the collection of seasons requested.</response>
/// <response code="500">Failed to get seasons.</response>
/// <returns>Returns a collection of seasons.</returns>
[MapToApiVersion("1.0")]
[HttpGet]
[ProducesResponseType(typeof(List<Season>), StatusCodes.Status200OK)]
@@ -35,10 +41,16 @@ namespace server.Controllers.v1
}
}
/// <summary>
/// Gets a season by its number.
/// </summary>
/// <response code="200">Returns the season requested.</response>
/// <response code="404">Could not find a seaon with number provided.</response>
/// <response code="500">Failed to get season.</response>
/// <returns>Returns the season requested</returns>
[MapToApiVersion("1.0")]
[HttpGet("{number:int}")]
[ProducesResponseType(typeof(Season), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<Season>> GetSeasonByNumberAsync(int number)
@@ -47,9 +59,9 @@ namespace server.Controllers.v1
{
var season = await _seasonRepository.GetSeasonByNumberAsync(number);
if (season == null) return Problem(detail: $"Could not find season {number}", statusCode: 404);
return Ok(season);
return season == null ?
Problem(detail: $"Could not find season {number}", statusCode: 404) :
Ok(season);
}
catch (Exception e)
{