|
|
@ -14,6 +14,9 @@ using Unleash.ClientFactory;
|
|
|
|
using Unleash;
|
|
|
|
using Unleash;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using isnd.Services;
|
|
|
|
using isnd.Services;
|
|
|
|
|
|
|
|
using isnd.Entities;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
|
|
|
using isnd.Helpers;
|
|
|
|
|
|
|
|
|
|
|
|
namespace isn.Controllers
|
|
|
|
namespace isn.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -30,14 +33,17 @@ namespace isn.Controllers
|
|
|
|
private readonly IDataProtector protector;
|
|
|
|
private readonly IDataProtector protector;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly NugetSettings nugetSettings;
|
|
|
|
private readonly NugetSettings nugetSettings;
|
|
|
|
ApplicationDbContext dbContext;
|
|
|
|
readonly ApplicationDbContext dbContext;
|
|
|
|
private PackageManager packageManager;
|
|
|
|
private readonly PackageManager packageManager;
|
|
|
|
|
|
|
|
private readonly IUnleash _unleashĈlient;
|
|
|
|
|
|
|
|
|
|
|
|
public PackagesController(
|
|
|
|
public PackagesController(
|
|
|
|
PackageManager packageManager,
|
|
|
|
PackageManager packageManager,
|
|
|
|
ILoggerFactory loggerFactory,
|
|
|
|
ILoggerFactory loggerFactory,
|
|
|
|
IDataProtectionProvider provider,
|
|
|
|
IDataProtectionProvider provider,
|
|
|
|
IOptions<NugetSettings> nugetOptions,
|
|
|
|
IOptions<NugetSettings> nugetOptions,
|
|
|
|
|
|
|
|
IOptions<UnleashClientSettings> unleashClientSettings,
|
|
|
|
|
|
|
|
IHostingEnvironment env,
|
|
|
|
ApplicationDbContext dbContext)
|
|
|
|
ApplicationDbContext dbContext)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger = loggerFactory.CreateLogger<PackagesController>();
|
|
|
|
logger = loggerFactory.CreateLogger<PackagesController>();
|
|
|
@ -45,8 +51,8 @@ namespace isn.Controllers
|
|
|
|
protector = provider.CreateProtector(nugetSettings.ProtectionTitle);
|
|
|
|
protector = provider.CreateProtector(nugetSettings.ProtectionTitle);
|
|
|
|
this.dbContext = dbContext;
|
|
|
|
this.dbContext = dbContext;
|
|
|
|
this.packageManager = packageManager;
|
|
|
|
this.packageManager = packageManager;
|
|
|
|
|
|
|
|
_unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
|
|
|
ressources = packageManager.GetResources(Startup.UnleashĈlient).ToArray();
|
|
|
|
ressources = packageManager.GetResources(_unleashĈlient).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// dotnet add . package -s http://localhost:5000/packages isn
|
|
|
|
// dotnet add . package -s http://localhost:5000/packages isn
|
|
|
@ -66,7 +72,7 @@ namespace isn.Controllers
|
|
|
|
[HttpGet(_pkgRootPrefix + "/index.json")]
|
|
|
|
[HttpGet(_pkgRootPrefix + "/index.json")]
|
|
|
|
public IActionResult Index(
|
|
|
|
public IActionResult Index(
|
|
|
|
string q,
|
|
|
|
string q,
|
|
|
|
string semVerLevel = defaultSemVer,
|
|
|
|
string semVerLevel,
|
|
|
|
bool prerelease = false,
|
|
|
|
bool prerelease = false,
|
|
|
|
string packageType = null,
|
|
|
|
string packageType = null,
|
|
|
|
int skip = 0,
|
|
|
|
int skip = 0,
|
|
|
@ -80,6 +86,10 @@ namespace isn.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ModelState.AddModelError("take", "Maximum exceeded");
|
|
|
|
ModelState.AddModelError("take", "Maximum exceeded");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (semVerLevel != defaultSemVer)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ModelState.AddModelError("semVerLevel", defaultSemVer + " expected");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Ok(packageManager.SearchByName(q,skip,take,prerelease,packageType));
|
|
|
|
return Ok(packageManager.SearchByName(q,skip,take,prerelease,packageType));
|
|
|
@ -91,7 +101,7 @@ namespace isn.Controllers
|
|
|
|
[HttpGet(_pkgRootPrefix + "/autocomplete")]
|
|
|
|
[HttpGet(_pkgRootPrefix + "/autocomplete")]
|
|
|
|
public IActionResult AutoComplete(
|
|
|
|
public IActionResult AutoComplete(
|
|
|
|
string id,
|
|
|
|
string id,
|
|
|
|
string semVerLevel = defaultSemVer,
|
|
|
|
string semVerLevel,
|
|
|
|
bool prerelease = false,
|
|
|
|
bool prerelease = false,
|
|
|
|
string packageType = null,
|
|
|
|
string packageType = null,
|
|
|
|
int skip = 0,
|
|
|
|
int skip = 0,
|
|
|
@ -102,6 +112,10 @@ namespace isn.Controllers
|
|
|
|
ModelState.AddModelError("take", "Maximum exceeded");
|
|
|
|
ModelState.AddModelError("take", "Maximum exceeded");
|
|
|
|
return BadRequest(ModelState);
|
|
|
|
return BadRequest(ModelState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (semVerLevel != defaultSemVer)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ModelState.AddModelError("semVerLevel", defaultSemVer + " expected");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Ok(packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
|
|
|
return Ok(packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|