v3 API prefix

This commit is contained in:
Paul Schneider 2026-07-05 20:17:12 +01:00
commit cd72b7b9aa
16 changed files with 24 additions and 32 deletions

View file

@ -12,7 +12,7 @@ isnd&
# get an api-key from <http://localhost:5000/ApkKeys>
isn push -k <lame-api-key> -s http://localhost:5000/index.json your-lame-versionned.nupkg
isn push -k <lame-api-key> -s http://localhost:5000/api/v3/index.json your-lame-versionned.nupkg
wget http://localhost:5000/package/index.json?q=your&prerelease=true&semVerLevel=2.0.0
````
@ -66,7 +66,10 @@ sudo ln -s /usr/local/lib/isn/isn /usr/local/bin/isn
set -e
# compiler tout
dotnet build -c Release
dotnet publish -c Release -f net10.0 src/isnd
# publier
dotnet publish -c Release src/isnd
dotnet publish -c Release src/isn
# MAJ du serveur
sudo systemctl stop isnd
sudo cp -a src/isnd/bin/Release/net10.0/publish/* /srv/www/isnd

View file

@ -1,2 +0,0 @@
nuget install -Verbosity detailed -Source http://localhost:5000/index.json -Prerelease Yavsc.Abstract
nuget locals all -clear

View file

@ -1,4 +0,0 @@
= URL's
<http://localhost:5000/v3.4.0/registration/yavsc.abstract/index.json>

View file

@ -5,6 +5,10 @@ namespace Isn.Abstract
public const string PaquetFileEstension = "nupkg";
public const string SpecFileEstension = "nuspec";
public const string JsonFileEstension = "json";
public const string PackageRootServerPrefix = "~/pkgs/";
/**
* The prefix for API routes.
*/
public const string APIPrefix = "api/v3/";
}
}

View file

@ -29,7 +29,7 @@ namespace isnd.Controllers
/// API index
/// </summary>
/// <returns></returns>
[HttpGet(Constants.PackageRootServerPrefix + ApiConfig.IndexDotJson)]
[HttpGet("~/" + Constants.APIPrefix + ApiConfig.IndexDotJson)]
public IActionResult ApiIndex()
{
return Ok(new ApiIndexViewModel(packageManager.CatalogBaseUrl + ApiConfig.IndexDotJson){ Version = PackageManager.BASE_API_LEVEL, Resources = resources });

View file

@ -9,7 +9,7 @@ namespace isnd.Controllers
{
// GET /autocomplete?id=isn.protocol&prerelease=true
[HttpGet(Constants.PackageRootServerPrefix + ApiConfig.AutoComplete)]
[HttpGet("~/" + Constants.APIPrefix + ApiConfig.AutoComplete)]
public IActionResult AutoComplete(
string id,
string semVerLevel,

View file

@ -16,14 +16,14 @@ namespace isnd.Controllers
{
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
[HttpGet(Constants.PackageRootServerPrefix + ApiConfig.Catalog)]
[HttpGet("~/" + Constants.APIPrefix + ApiConfig.Catalog)]
public async Task<IActionResult> CatalogIndex()
{
return Ok(await packageManager.GetCatalogIndexAsync());
}
[HttpGet(Constants.PackageRootServerPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{lower}.json")]
[HttpGet("~/" + Constants.APIPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{lower}.json")]
public async Task<IActionResult> CatalogRegistration(string apiVersion, string id, string lower)
{
if (lower.Equals("index", System.StringComparison.InvariantCultureIgnoreCase))

View file

@ -11,7 +11,7 @@ namespace isnd.Controllers
{
public partial class PackagesController
{
[HttpDelete(Constants.PackageRootServerPrefix + ApiConfig.Delete + "/{id}/{lower?}/{type?}")]
[HttpDelete("~/" + Constants.APIPrefix + ApiConfig.Delete + "/{id}/{lower?}/{type?}")]
public async Task<IActionResult> ApiDelete(
[FromRoute][SafeName][Required] string id,
[FromRoute][SafeName][Required] string lower,

View file

@ -11,7 +11,7 @@ namespace isnd.Controllers
public partial class PackagesController
{
// Web get the paquet
[HttpGet(Constants.PackageRootServerPrefix + ApiConfig.GetPackage + "/{id}/{lower}/{idf}-{lowerf}."
[HttpGet("~/" + Constants.APIPrefix + ApiConfig.GetPackage + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.PaquetFileEstension)]
public IActionResult GetPackage(
[FromRoute][SafeName][Required] string id,
@ -32,7 +32,7 @@ namespace isnd.Controllers
}
// Web get spec
[HttpGet(Constants.PackageRootServerPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
[HttpGet("~/" + Constants.APIPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.SpecFileEstension)]
public IActionResult GetNuspec(
[FromRoute][SafeName][Required] string id,

View file

@ -7,7 +7,7 @@ namespace isnd.Controllers
{
public partial class PackagesController
{
[HttpGet(Constants.PackageRootServerPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.IndexDotJson)]
[HttpGet("~/" + Constants.APIPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.IndexDotJson)]
public IActionResult GetVersions(
string id,
string lower,

View file

@ -25,7 +25,7 @@ namespace isnd.Controllers
public partial class PackagesController
{
// TODO [Authorize(Policy = IsndConstants.RequireValidApiKey)]
[HttpPut(Constants.PackageRootServerPrefix + ApiConfig.Publish)]
[HttpPut("~/" + Constants.APIPrefix + ApiConfig.Publish)]
public async Task<IActionResult> Put()
{
try

View file

@ -11,7 +11,7 @@ namespace isnd.Controllers
public partial class PackagesController
{
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
[HttpGet(Constants.PackageRootServerPrefix + ApiConfig.Search)]
[HttpGet("~/" + Constants.APIPrefix + ApiConfig.Search)]
public IActionResult Search(
string q,
int skip = 0,

View file

@ -31,7 +31,7 @@ namespace isnd.Services
{
this.dbContext = dbContext;
isndSettings = siteConfigOptionsOptions.Value;
extUrl = isndSettings.ExternalUrl + "/";
extUrl = isndSettings.ExternalUrl + "/" +Constants.APIPrefix;
}
/**

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<apikeys>
</apikeys>
<packageSources>
<add key="dev" value="http://localhost:5000/index.json" protocolVersion="3" />
<!-- <add key="isn-prod" value="https://isn.pschneider.fr/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> -->
</packageSources>
</configuration>

View file

@ -22,7 +22,7 @@ namespace Isn.tests
public LocalSourceFixture()
{
var port = GetFreePort();
var prefix = $"http://127.0.0.1:{port}/";
var prefix = $"http://127.0.0.1:{port}/"+Constants.APIPrefix;
listener = new HttpListener();
listener.Prefixes.Add(prefix);
listener.Start();

View file

@ -18,6 +18,7 @@ using NuGet.Configuration;
using System.Threading.Tasks;
using NuGet.Protocol.Core.Types;
using NuGet.Common;
using Isn.Abstract;
namespace isnd.host.tests
{
@ -72,7 +73,7 @@ namespace isnd.host.tests
using (var serviceScope = server.Host.Services.CreateScope())
{
var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value;
string pkgSourceUrl = isnSettings.ExternalUrl + "/pkgs/index.json";
string pkgSourceUrl = isnSettings.ExternalUrl + "/" + Constants.APIPrefix + "index.json";
using var client = new HttpClient();
var response = client.GetAsync(pkgSourceUrl).GetAwaiter().GetResult();
var body = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();