From 386cb247c61d6062163d5723afac902a68c05d86 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Wed, 1 Apr 2020 22:21:19 -0600 Subject: [PATCH] Add Nexus data export endpoint --- .../Controllers/NexusCache.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Wabbajack.BuildServer/Controllers/NexusCache.cs b/Wabbajack.BuildServer/Controllers/NexusCache.cs index ce6179d7..c938db34 100644 --- a/Wabbajack.BuildServer/Controllers/NexusCache.cs +++ b/Wabbajack.BuildServer/Controllers/NexusCache.cs @@ -1,10 +1,13 @@ using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using MongoDB.Driver; +using Newtonsoft.Json; using Wabbajack.BuildServer.Model.Models; using Wabbajack.BuildServer.Models; +using Wabbajack.Common; using Wabbajack.Lib.NexusApi; namespace Wabbajack.BuildServer.Controllers @@ -120,5 +123,21 @@ namespace Wabbajack.BuildServer.Controllers Response.Headers.Add("x-cache-method", method); return result.Data; } + + [HttpPost] + [Authorize] + [Route("/nexus_api_cache/export")] + public async Task ExportNexusCache() + { + Utils.Log("Exporting Nexus Info"); + var file_infos = Db.NexusFileInfos.AsQueryable().ToListAsync(); + var mod_infos = Db.NexusModInfos.AsQueryable().ToListAsync(); + var mod_files = Db.NexusModFiles.AsQueryable().ToListAsync(); + + var data = new {FileInfos = await file_infos, ModInfos = await mod_infos, Modfiles = await mod_files,}; + Utils.Log("Writing Data"); + return Ok(JsonConvert.SerializeObject(data)); + + } } }