forked from loic-sharma/BaGet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add v3-flatcontainer as in api.nuget.com. Merge PR: loic-sharma#752
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using BaGet.Core; | ||
using BaGet.Web.Dtos; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace BaGet.Web.Controllers | ||
{ | ||
[Route("v3-flatcontainer/{packageId}/index.json")] | ||
[ApiController] | ||
public class VersionsController : ControllerBase | ||
{ | ||
private readonly IPackageDatabase _packageDatabase; | ||
public VersionsController(IPackageDatabase packageDatabase) | ||
{ | ||
_packageDatabase = packageDatabase; | ||
} | ||
|
||
[HttpGet] | ||
public async Task<ActionResult<IEnumerable<string>>> GetVersionsForPackage(string packageId) | ||
{ | ||
Console.WriteLine($"--> Getting versions for package {packageId} from Automaise nuget"); | ||
var exists = await _packageDatabase.ExistsAsync(packageId, new System.Threading.CancellationToken()); | ||
if (!exists) | ||
return NotFound(); | ||
var retVersions = await _packageDatabase.FindAsync(packageId, true, new System.Threading.CancellationToken()); | ||
var versionDto = new VersionDto(); | ||
versionDto.versions = retVersions.Select(x => x.Version.ToString()).ToList(); | ||
return Ok(versionDto); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace BaGet.Web.Dtos | ||
{ | ||
public class VersionDto | ||
{ | ||
public List<string> versions { get; set; } = new List<string>(); | ||
} | ||
} |