diff --git a/README.md b/README.md index 098b9c3..b4f0003 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ isnd& # get an api-key from -isn push -k -s http://localhost:5000/index.json your-lame-versionned.nupkg +isn push -k -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 diff --git a/contrib/testinstnuget/call.lines b/contrib/testinstnuget/call.lines index c6abc1a..e69de29 100644 --- a/contrib/testinstnuget/call.lines +++ b/contrib/testinstnuget/call.lines @@ -1,2 +0,0 @@ -nuget install -Verbosity detailed -Source http://localhost:5000/index.json -Prerelease Yavsc.Abstract -nuget locals all -clear diff --git a/contrib/testinstnuget/urls.adoc b/contrib/testinstnuget/urls.adoc deleted file mode 100644 index 5c81113..0000000 --- a/contrib/testinstnuget/urls.adoc +++ /dev/null @@ -1,4 +0,0 @@ -= URL's - - - diff --git a/src/isn.abstract/Constants.cs b/src/isn.abstract/Constants.cs index 01d2914..1a12cc5 100644 --- a/src/isn.abstract/Constants.cs +++ b/src/isn.abstract/Constants.cs @@ -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/"; } } \ No newline at end of file diff --git a/src/isnd/Controllers/Packages/ApiIndex.cs b/src/isnd/Controllers/Packages/ApiIndex.cs index eb2fc87..1a1e435 100644 --- a/src/isnd/Controllers/Packages/ApiIndex.cs +++ b/src/isnd/Controllers/Packages/ApiIndex.cs @@ -29,7 +29,7 @@ namespace isnd.Controllers /// API index /// /// - [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 }); diff --git a/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs b/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs index 57cd4b5..b3d5711 100644 --- a/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs +++ b/src/isnd/Controllers/Packages/PackagesController.AutoComplete.cs @@ -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, diff --git a/src/isnd/Controllers/Packages/PackagesController.Catalog.cs b/src/isnd/Controllers/Packages/PackagesController.Catalog.cs index 7e74a56..a1a7f3c 100644 --- a/src/isnd/Controllers/Packages/PackagesController.Catalog.cs +++ b/src/isnd/Controllers/Packages/PackagesController.Catalog.cs @@ -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 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 CatalogRegistration(string apiVersion, string id, string lower) { if (lower.Equals("index", System.StringComparison.InvariantCultureIgnoreCase)) diff --git a/src/isnd/Controllers/Packages/PackagesController.Delete.cs b/src/isnd/Controllers/Packages/PackagesController.Delete.cs index e117de5..bccefb4 100644 --- a/src/isnd/Controllers/Packages/PackagesController.Delete.cs +++ b/src/isnd/Controllers/Packages/PackagesController.Delete.cs @@ -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 ApiDelete( [FromRoute][SafeName][Required] string id, [FromRoute][SafeName][Required] string lower, diff --git a/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs b/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs index b5b7836..8e42b69 100644 --- a/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs +++ b/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs @@ -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, diff --git a/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs b/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs index f6a974d..55cfad9 100644 --- a/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs +++ b/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs @@ -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, diff --git a/src/isnd/Controllers/Packages/PackagesController.Put.cs b/src/isnd/Controllers/Packages/PackagesController.Put.cs index b05691e..3f82924 100644 --- a/src/isnd/Controllers/Packages/PackagesController.Put.cs +++ b/src/isnd/Controllers/Packages/PackagesController.Put.cs @@ -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 Put() { try diff --git a/src/isnd/Controllers/Packages/PackagesController.Search.cs b/src/isnd/Controllers/Packages/PackagesController.Search.cs index 8088bd8..61c19d1 100644 --- a/src/isnd/Controllers/Packages/PackagesController.Search.cs +++ b/src/isnd/Controllers/Packages/PackagesController.Search.cs @@ -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, diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs index 8474ec9..ac66bda 100644 --- a/src/isnd/Services/PackageManager.cs +++ b/src/isnd/Services/PackageManager.cs @@ -31,7 +31,7 @@ namespace isnd.Services { this.dbContext = dbContext; isndSettings = siteConfigOptionsOptions.Value; - extUrl = isndSettings.ExternalUrl + "/"; + extUrl = isndSettings.ExternalUrl + "/" +Constants.APIPrefix; } /** diff --git a/test/data/test-isn/ANuGet.Config b/test/data/test-isn/ANuGet.Config deleted file mode 100644 index 072ade1..0000000 --- a/test/data/test-isn/ANuGet.Config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/test/isn.tests/PushTest.cs b/test/isn.tests/PushTest.cs index a53ebf5..b4223fc 100644 --- a/test/isn.tests/PushTest.cs +++ b/test/isn.tests/PushTest.cs @@ -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(); diff --git a/test/isnd.tests/UnitTestWebHost.cs b/test/isnd.tests/UnitTestWebHost.cs index 96a1203..3ca896f 100644 --- a/test/isnd.tests/UnitTestWebHost.cs +++ b/test/isnd.tests/UnitTestWebHost.cs @@ -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>().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();