commit 3fa130d2823f1416f0fc47fc4ae7c20c18393064 Author: David Meincke Date: Fri May 12 09:43:35 2023 +0200 add to git diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..83129e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/.vs/CodeEditorApi +/Application/.config +/Application/.vs/CodeEditorApi +/Application/bin +/Application/obj +/Application/Properties diff --git a/Application/CodeEditorApi.csproj b/Application/CodeEditorApi.csproj new file mode 100644 index 0000000..0ef9c44 --- /dev/null +++ b/Application/CodeEditorApi.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/Application/CodeEditorApi.csproj.user b/Application/CodeEditorApi.csproj.user new file mode 100644 index 0000000..4181228 --- /dev/null +++ b/Application/CodeEditorApi.csproj.user @@ -0,0 +1,6 @@ + + + + C:\Projects\code-editor-api\Application\Properties\PublishProfiles\FTPProfile.pubxml + + \ No newline at end of file diff --git a/Application/CodeEditorApi.sln b/Application/CodeEditorApi.sln new file mode 100644 index 0000000..11e4f8b --- /dev/null +++ b/Application/CodeEditorApi.sln @@ -0,0 +1,13 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33627.172 +MinimumVisualStudioVersion = 10.0.40219.1 +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1746F93F-3E42-4832-B5C1-834781B0426F} + EndGlobalSection +EndGlobal diff --git a/Application/Controllers/SessionController.cs b/Application/Controllers/SessionController.cs new file mode 100644 index 0000000..ff35efd --- /dev/null +++ b/Application/Controllers/SessionController.cs @@ -0,0 +1,41 @@ +using CodeEditorApi.Helpers; +using Microsoft.AspNetCore.Mvc; + +namespace CodeEditorApi.Controllers +{ + [ApiController] + [Route("[controller]")] + public class SessionController : ControllerBase + { + private readonly ILogger _logger; + + public SessionController(ILogger logger) + { + _logger = logger; + } + + [HttpPost("create")] + public Session CreateSession([FromBody] Session newSession) + { + return SessionFiles.Create(newSession.Id); + } + + [HttpPost("set")] + public void SetData([FromBody] SessionData data) + { + SessionFiles.Save(data); + } + + [HttpGet("all")] + public IEnumerable Sessions() + { + return SessionFiles.Get(); + } + + [HttpGet("data/{sessionId}")] + public IEnumerable SessionData(Guid sessionId) + { + return SessionFiles.Get(sessionId); + } + } +} \ No newline at end of file diff --git a/Application/Database/1820440b-1b8f-4d92-82c9-c59cf0f0f51d/2023-05-11T18-36-47-304.js b/Application/Database/1820440b-1b8f-4d92-82c9-c59cf0f0f51d/2023-05-11T18-36-47-304.js new file mode 100644 index 0000000..7ab6a5a --- /dev/null +++ b/Application/Database/1820440b-1b8f-4d92-82c9-c59cf0f0f51d/2023-05-11T18-36-47-304.js @@ -0,0 +1 @@ +console.log("HELLO"); \ No newline at end of file diff --git a/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b2/2022-01-01T00-00-00-000.js b/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b2/2022-01-01T00-00-00-000.js new file mode 100644 index 0000000..0dd3e70 --- /dev/null +++ b/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b2/2022-01-01T00-00-00-000.js @@ -0,0 +1 @@ +var myJs = true; \ No newline at end of file diff --git a/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b2/2022-01-02T00-00-00-000.js b/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b2/2022-01-02T00-00-00-000.js new file mode 100644 index 0000000..64209a3 --- /dev/null +++ b/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b2/2022-01-02T00-00-00-000.js @@ -0,0 +1 @@ +var myJs = true; var myOtherThing = 'string' \ No newline at end of file diff --git a/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b3/2022-01-02T00-00-00-000.js b/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b3/2022-01-02T00-00-00-000.js new file mode 100644 index 0000000..64209a3 --- /dev/null +++ b/Application/Database/9ec274a6-f2a1-4629-b52a-a0d5e72eb4b3/2022-01-02T00-00-00-000.js @@ -0,0 +1 @@ +var myJs = true; var myOtherThing = 'string' \ No newline at end of file diff --git a/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-17-118.js b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-17-118.js new file mode 100644 index 0000000..0b2963a --- /dev/null +++ b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-17-118.js @@ -0,0 +1 @@ +console.log("Hello") \ No newline at end of file diff --git a/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-27-499.js b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-27-499.js new file mode 100644 index 0000000..043b6e1 --- /dev/null +++ b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-27-499.js @@ -0,0 +1 @@ +console.log("Hello 2.01") \ No newline at end of file diff --git a/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-32-728.js b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-32-728.js new file mode 100644 index 0000000..0bd4587 --- /dev/null +++ b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-32-728.js @@ -0,0 +1 @@ +console.log("Hello 3.1") \ No newline at end of file diff --git a/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-34-842.js b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-34-842.js new file mode 100644 index 0000000..0de561d --- /dev/null +++ b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T14-19-34-842.js @@ -0,0 +1 @@ +console.log("Hello 3.1"); \ No newline at end of file diff --git a/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T16-11-10-281.js b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T16-11-10-281.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/a4e275a9-b15d-4d95-b1a3-5b99d441a370/2023-05-11T16-11-10-281.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-05-271.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-05-271.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-05-271.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-06-277.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-06-277.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-06-277.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-08-271.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-08-271.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-08-271.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-10-279.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-10-279.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-10-279.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-12-278.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-12-278.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-12-278.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-14-276.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-14-276.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-14-276.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-17-275.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-17-275.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-17-275.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-18-287.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-18-287.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-18-287.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-20-277.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-20-277.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-20-277.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-22-278.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-22-278.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-22-278.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-25-277.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-25-277.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-25-277.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-27-266.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-27-266.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-27-266.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-28-274.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-28-274.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-28-274.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-31-276.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-31-276.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-31-276.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-33-269.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-33-269.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-33-269.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-34-278.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-34-278.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-34-278.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-37-268.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-37-268.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-37-268.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-39-276.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-39-276.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-39-276.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-41-265.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-41-265.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-41-265.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-42-279.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-42-279.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-42-279.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-44-280.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-44-280.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-44-280.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-46-275.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-46-275.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-46-275.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-49-274.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-49-274.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-49-274.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-51-279.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-51-279.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-51-279.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-53-268.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-53-268.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-53-268.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-55-266.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-55-266.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-55-266.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-56-275.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-56-275.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-56-275.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-59-280.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-59-280.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-37-59-280.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-00-286.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-00-286.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-00-286.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-08-477.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-08-477.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-08-477.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-17-104.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-17-104.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-17-104.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-47-035.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-47-035.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-38-47-035.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-44-04-217.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-44-04-217.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-44-04-217.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-44-38-039.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-44-38-039.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-44-38-039.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-55-48-664.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-55-48-664.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-55-48-664.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-57-37-991.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-57-37-991.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T16-57-37-991.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T17-06-32-652.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T17-06-32-652.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T17-06-32-652.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-09-39-460.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-09-39-460.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-09-39-460.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-09-56-720.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-09-56-720.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-09-56-720.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-10-33-847.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-10-33-847.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-10-33-847.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-27-39-789.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-27-39-789.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-27-39-789.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-27-47-765.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-27-47-765.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-27-47-765.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-28-05-292.js b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-28-05-292.js new file mode 100644 index 0000000..e51fc8e --- /dev/null +++ b/Application/Database/bcb43541-ae31-41e8-8fda-a007e135f00c/2023-05-11T18-28-05-292.js @@ -0,0 +1 @@ +box(10, 10, 10, 10) \ No newline at end of file diff --git a/Application/Helpers/SessionFiles.cs b/Application/Helpers/SessionFiles.cs new file mode 100644 index 0000000..1968784 --- /dev/null +++ b/Application/Helpers/SessionFiles.cs @@ -0,0 +1,171 @@ +using Newtonsoft.Json; +using System.Globalization; +using System.IO; +using System.Net.WebSockets; +using System.Text; +using System.Text.Json.Serialization; + +namespace CodeEditorApi.Helpers +{ + public static class SessionFiles + { + private static string sessionPath = "database/"; + public static Session Create(Guid sessionId) + { + if (CheckForDirectoryExists(sessionId)) + { + throw new Exception("Session already exists"); + } + else + { + CreateDirectory(sessionId); + } + + return GetSession(sessionPath + "/" + sessionId); + } + + public static void Save(SessionData data) + { + if (!CheckForDirectoryExists(data.SessionId)) + { + CreateDirectory(data.SessionId); + } + + WriteFile(data); + } + + public static Session[] Get() + { + var dir = Directory.GetDirectories(sessionPath); + var res = new List(); + + foreach (var folder in dir) + { + var files = Directory.GetFiles(folder); + + res.Add(GetSession(folder)); + } + + return res.ToArray(); + } + + public static SessionData[] Get(Guid sessionId) + { + var fileNames = Directory.GetFiles(sessionPath + "/" + sessionId); + var res = new List(); + + foreach (var fileName in fileNames) + { + res.Add(GetSessionData(sessionId, fileName)); + } + + return res.ToArray(); + } + + private static bool CheckForDirectoryExists(Guid sessionId) + { + if (Directory.Exists(sessionPath + sessionId)) + { + return true; + } + else + { + return false; + } + } + + private static bool CreateDirectory(Guid sessionId) + { + Directory.CreateDirectory(sessionPath + sessionId); + return true; + } + + private static bool CreateFile(SessionData data) + { + if (!File.Exists(sessionPath + data.FileName)) + { + using (FileStream fs = File.Create(sessionPath + data.FileName)) + { + } + + } + + return true; + } + + private static bool WriteFile(SessionData data) + { + CreateFile(data); + using (StreamWriter sw = File.CreateText(sessionPath + data.FileName)) + { + sw.Write(data.Data); + } + + return true; + } + + private static DataType GetExtension(string fileName) + { + if (fileName.EndsWith(".js")) + { + return DataType.Javascript; + } + else if (fileName.EndsWith(".css")) + { + return DataType.CSS; + } + else if (fileName.EndsWith(".html")) + { + return DataType.HTML; + } + + return DataType.Text; + } + + private static Session GetSession(string path) + { + var files = Directory.GetFiles(path); + + var strId = path.Substring(path.LastIndexOf("/") + 1); + + var session = new Session + { + Id = Guid.Parse(strId), + NumberOfChanges = files.Length + }; + + return session; + } + + private static SessionData GetSessionData(Guid sessionId, string path) + { + SessionData sessionData; + + using (StreamReader sr = new StreamReader(path)) + { + var content = sr.ReadToEnd(); + + sessionData = new SessionData + { + SessionId = sessionId, + Data = content, + Type = GetExtension(path), + Timestamp = DateTime.Now + }; + } + + return sessionData; + } + + public static string GetFormattedDate(DateTime date) + { + return date.ToString("yyyy-MM-ddTHH-mm-ss-fff"); + } + + public static DateTime GetDateFromFormat(string date) + { + CultureInfo provider = CultureInfo.InvariantCulture; + return DateTime.ParseExact(date, "yyyy-MM-ddTHH-mm-ss-fff", provider); + } + } +} diff --git a/Application/Program.cs b/Application/Program.cs new file mode 100644 index 0000000..38ba7d9 --- /dev/null +++ b/Application/Program.cs @@ -0,0 +1,24 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.UseCors(options => +{ + options.AllowAnyHeader(); + options.AllowAnyMethod(); + options.AllowAnyOrigin(); +}); + +app.Run(); diff --git a/Application/Session.cs b/Application/Session.cs new file mode 100644 index 0000000..8a3d5ac --- /dev/null +++ b/Application/Session.cs @@ -0,0 +1,8 @@ +namespace CodeEditorApi +{ + public class Session + { + public Guid Id { get; set; } + public int NumberOfChanges { get; set; } + } +} diff --git a/Application/SessionData.cs b/Application/SessionData.cs new file mode 100644 index 0000000..1db4134 --- /dev/null +++ b/Application/SessionData.cs @@ -0,0 +1,46 @@ +namespace CodeEditorApi +{ + public class SessionData + { + public DateTime Timestamp { get; set; } + public Guid SessionId { get; set; } + public object Data { get; set; } = default!; + public DataType Type { get; set; } + + public string FileName + { + get + { + return SessionId.ToString() + "/" + Helpers.SessionFiles.GetFormattedDate(Timestamp) + FileExtension; + } + } + + public string FileExtension { + get + { + if (Type == DataType.Javascript) + { + return ".js"; + } + else if (Type == DataType.CSS) + { + return ".css"; + } + else if (Type == DataType.HTML) + { + return ".html"; + } + + return ".txt"; + } + } + } + + public enum DataType + { + Javascript, + HTML, + CSS, + Text + } +} diff --git a/Application/appsettings.Development.json b/Application/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Application/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Application/appsettings.json b/Application/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Application/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/CodeEditorApi.sln b/CodeEditorApi.sln new file mode 100644 index 0000000..901a005 --- /dev/null +++ b/CodeEditorApi.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33627.172 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeEditorApi", "Application\CodeEditorApi.csproj", "{FEB9C73E-0A8D-4105-A3AD-4740DF9D0998}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FEB9C73E-0A8D-4105-A3AD-4740DF9D0998}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FEB9C73E-0A8D-4105-A3AD-4740DF9D0998}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FEB9C73E-0A8D-4105-A3AD-4740DF9D0998}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FEB9C73E-0A8D-4105-A3AD-4740DF9D0998}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1746F93F-3E42-4832-B5C1-834781B0426F} + EndGlobalSection +EndGlobal