- commit
- a9b895d
- parent
- a9b895d
- author
- CheddarCrisp
- date
- 2024-02-12 19:39:57 +0100 CET
Initial commit
9 files changed,
+707,
-0
+484,
-0
1@@ -0,0 +1,484 @@
2+## Ignore Visual Studio temporary files, build results, and
3+## files generated by popular Visual Studio add-ons.
4+##
5+## Get latest from `dotnet new gitignore`
6+
7+# dotenv files
8+.env
9+
10+# User-specific files
11+*.rsuser
12+*.suo
13+*.user
14+*.userosscache
15+*.sln.docstates
16+
17+# User-specific files (MonoDevelop/Xamarin Studio)
18+*.userprefs
19+
20+# Mono auto generated files
21+mono_crash.*
22+
23+# Build results
24+[Dd]ebug/
25+[Dd]ebugPublic/
26+[Rr]elease/
27+[Rr]eleases/
28+x64/
29+x86/
30+[Ww][Ii][Nn]32/
31+[Aa][Rr][Mm]/
32+[Aa][Rr][Mm]64/
33+bld/
34+[Bb]in/
35+[Oo]bj/
36+[Ll]og/
37+[Ll]ogs/
38+
39+# Visual Studio 2015/2017 cache/options directory
40+.vs/
41+# Uncomment if you have tasks that create the project's static files in wwwroot
42+#wwwroot/
43+
44+# Visual Studio 2017 auto generated files
45+Generated\ Files/
46+
47+# MSTest test Results
48+[Tt]est[Rr]esult*/
49+[Bb]uild[Ll]og.*
50+
51+# NUnit
52+*.VisualState.xml
53+TestResult.xml
54+nunit-*.xml
55+
56+# Build Results of an ATL Project
57+[Dd]ebugPS/
58+[Rr]eleasePS/
59+dlldata.c
60+
61+# Benchmark Results
62+BenchmarkDotNet.Artifacts/
63+
64+# .NET
65+project.lock.json
66+project.fragment.lock.json
67+artifacts/
68+
69+# Tye
70+.tye/
71+
72+# ASP.NET Scaffolding
73+ScaffoldingReadMe.txt
74+
75+# StyleCop
76+StyleCopReport.xml
77+
78+# Files built by Visual Studio
79+*_i.c
80+*_p.c
81+*_h.h
82+*.ilk
83+*.meta
84+*.obj
85+*.iobj
86+*.pch
87+*.pdb
88+*.ipdb
89+*.pgc
90+*.pgd
91+*.rsp
92+*.sbr
93+*.tlb
94+*.tli
95+*.tlh
96+*.tmp
97+*.tmp_proj
98+*_wpftmp.csproj
99+*.log
100+*.tlog
101+*.vspscc
102+*.vssscc
103+.builds
104+*.pidb
105+*.svclog
106+*.scc
107+
108+# Chutzpah Test files
109+_Chutzpah*
110+
111+# Visual C++ cache files
112+ipch/
113+*.aps
114+*.ncb
115+*.opendb
116+*.opensdf
117+*.sdf
118+*.cachefile
119+*.VC.db
120+*.VC.VC.opendb
121+
122+# Visual Studio profiler
123+*.psess
124+*.vsp
125+*.vspx
126+*.sap
127+
128+# Visual Studio Trace Files
129+*.e2e
130+
131+# TFS 2012 Local Workspace
132+$tf/
133+
134+# Guidance Automation Toolkit
135+*.gpState
136+
137+# ReSharper is a .NET coding add-in
138+_ReSharper*/
139+*.[Rr]e[Ss]harper
140+*.DotSettings.user
141+
142+# TeamCity is a build add-in
143+_TeamCity*
144+
145+# DotCover is a Code Coverage Tool
146+*.dotCover
147+
148+# AxoCover is a Code Coverage Tool
149+.axoCover/*
150+!.axoCover/settings.json
151+
152+# Coverlet is a free, cross platform Code Coverage Tool
153+coverage*.json
154+coverage*.xml
155+coverage*.info
156+
157+# Visual Studio code coverage results
158+*.coverage
159+*.coveragexml
160+
161+# NCrunch
162+_NCrunch_*
163+.*crunch*.local.xml
164+nCrunchTemp_*
165+
166+# MightyMoose
167+*.mm.*
168+AutoTest.Net/
169+
170+# Web workbench (sass)
171+.sass-cache/
172+
173+# Installshield output folder
174+[Ee]xpress/
175+
176+# DocProject is a documentation generator add-in
177+DocProject/buildhelp/
178+DocProject/Help/*.HxT
179+DocProject/Help/*.HxC
180+DocProject/Help/*.hhc
181+DocProject/Help/*.hhk
182+DocProject/Help/*.hhp
183+DocProject/Help/Html2
184+DocProject/Help/html
185+
186+# Click-Once directory
187+publish/
188+
189+# Publish Web Output
190+*.[Pp]ublish.xml
191+*.azurePubxml
192+# Note: Comment the next line if you want to checkin your web deploy settings,
193+# but database connection strings (with potential passwords) will be unencrypted
194+*.pubxml
195+*.publishproj
196+
197+# Microsoft Azure Web App publish settings. Comment the next line if you want to
198+# checkin your Azure Web App publish settings, but sensitive information contained
199+# in these scripts will be unencrypted
200+PublishScripts/
201+
202+# NuGet Packages
203+*.nupkg
204+# NuGet Symbol Packages
205+*.snupkg
206+# The packages folder can be ignored because of Package Restore
207+**/[Pp]ackages/*
208+# except build/, which is used as an MSBuild target.
209+!**/[Pp]ackages/build/
210+# Uncomment if necessary however generally it will be regenerated when needed
211+#!**/[Pp]ackages/repositories.config
212+# NuGet v3's project.json files produces more ignorable files
213+*.nuget.props
214+*.nuget.targets
215+
216+# Microsoft Azure Build Output
217+csx/
218+*.build.csdef
219+
220+# Microsoft Azure Emulator
221+ecf/
222+rcf/
223+
224+# Windows Store app package directories and files
225+AppPackages/
226+BundleArtifacts/
227+Package.StoreAssociation.xml
228+_pkginfo.txt
229+*.appx
230+*.appxbundle
231+*.appxupload
232+
233+# Visual Studio cache files
234+# files ending in .cache can be ignored
235+*.[Cc]ache
236+# but keep track of directories ending in .cache
237+!?*.[Cc]ache/
238+
239+# Others
240+ClientBin/
241+~$*
242+*~
243+*.dbmdl
244+*.dbproj.schemaview
245+*.jfm
246+*.pfx
247+*.publishsettings
248+orleans.codegen.cs
249+
250+# Including strong name files can present a security risk
251+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
252+#*.snk
253+
254+# Since there are multiple workflows, uncomment next line to ignore bower_components
255+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
256+#bower_components/
257+
258+# RIA/Silverlight projects
259+Generated_Code/
260+
261+# Backup & report files from converting an old project file
262+# to a newer Visual Studio version. Backup files are not needed,
263+# because we have git ;-)
264+_UpgradeReport_Files/
265+Backup*/
266+UpgradeLog*.XML
267+UpgradeLog*.htm
268+ServiceFabricBackup/
269+*.rptproj.bak
270+
271+# SQL Server files
272+*.mdf
273+*.ldf
274+*.ndf
275+
276+# Business Intelligence projects
277+*.rdl.data
278+*.bim.layout
279+*.bim_*.settings
280+*.rptproj.rsuser
281+*- [Bb]ackup.rdl
282+*- [Bb]ackup ([0-9]).rdl
283+*- [Bb]ackup ([0-9][0-9]).rdl
284+
285+# Microsoft Fakes
286+FakesAssemblies/
287+
288+# GhostDoc plugin setting file
289+*.GhostDoc.xml
290+
291+# Node.js Tools for Visual Studio
292+.ntvs_analysis.dat
293+node_modules/
294+
295+# Visual Studio 6 build log
296+*.plg
297+
298+# Visual Studio 6 workspace options file
299+*.opt
300+
301+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
302+*.vbw
303+
304+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
305+*.vbp
306+
307+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
308+*.dsw
309+*.dsp
310+
311+# Visual Studio 6 technical files
312+*.ncb
313+*.aps
314+
315+# Visual Studio LightSwitch build output
316+**/*.HTMLClient/GeneratedArtifacts
317+**/*.DesktopClient/GeneratedArtifacts
318+**/*.DesktopClient/ModelManifest.xml
319+**/*.Server/GeneratedArtifacts
320+**/*.Server/ModelManifest.xml
321+_Pvt_Extensions
322+
323+# Paket dependency manager
324+.paket/paket.exe
325+paket-files/
326+
327+# FAKE - F# Make
328+.fake/
329+
330+# CodeRush personal settings
331+.cr/personal
332+
333+# Python Tools for Visual Studio (PTVS)
334+__pycache__/
335+*.pyc
336+
337+# Cake - Uncomment if you are using it
338+# tools/**
339+# !tools/packages.config
340+
341+# Tabs Studio
342+*.tss
343+
344+# Telerik's JustMock configuration file
345+*.jmconfig
346+
347+# BizTalk build output
348+*.btp.cs
349+*.btm.cs
350+*.odx.cs
351+*.xsd.cs
352+
353+# OpenCover UI analysis results
354+OpenCover/
355+
356+# Azure Stream Analytics local run output
357+ASALocalRun/
358+
359+# MSBuild Binary and Structured Log
360+*.binlog
361+
362+# NVidia Nsight GPU debugger configuration file
363+*.nvuser
364+
365+# MFractors (Xamarin productivity tool) working folder
366+.mfractor/
367+
368+# Local History for Visual Studio
369+.localhistory/
370+
371+# Visual Studio History (VSHistory) files
372+.vshistory/
373+
374+# BeatPulse healthcheck temp database
375+healthchecksdb
376+
377+# Backup folder for Package Reference Convert tool in Visual Studio 2017
378+MigrationBackup/
379+
380+# Ionide (cross platform F# VS Code tools) working folder
381+.ionide/
382+
383+# Fody - auto-generated XML schema
384+FodyWeavers.xsd
385+
386+# VS Code files for those working on multiple tools
387+.vscode/*
388+!.vscode/settings.json
389+!.vscode/tasks.json
390+!.vscode/launch.json
391+!.vscode/extensions.json
392+*.code-workspace
393+
394+# Local History for Visual Studio Code
395+.history/
396+
397+# Windows Installer files from build outputs
398+*.cab
399+*.msi
400+*.msix
401+*.msm
402+*.msp
403+
404+# JetBrains Rider
405+*.sln.iml
406+.idea
407+
408+##
409+## Visual studio for Mac
410+##
411+
412+
413+# globs
414+Makefile.in
415+*.userprefs
416+*.usertasks
417+config.make
418+config.status
419+aclocal.m4
420+install-sh
421+autom4te.cache/
422+*.tar.gz
423+tarballs/
424+test-results/
425+
426+# Mac bundle stuff
427+*.dmg
428+*.app
429+
430+# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
431+# General
432+.DS_Store
433+.AppleDouble
434+.LSOverride
435+
436+# Icon must end with two \r
437+Icon
438+
439+
440+# Thumbnails
441+._*
442+
443+# Files that might appear in the root of a volume
444+.DocumentRevisions-V100
445+.fseventsd
446+.Spotlight-V100
447+.TemporaryItems
448+.Trashes
449+.VolumeIcon.icns
450+.com.apple.timemachine.donotpresent
451+
452+# Directories potentially created on remote AFP share
453+.AppleDB
454+.AppleDesktop
455+Network Trash Folder
456+Temporary Items
457+.apdisk
458+
459+# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
460+# Windows thumbnail cache files
461+Thumbs.db
462+ehthumbs.db
463+ehthumbs_vista.db
464+
465+# Dump file
466+*.stackdump
467+
468+# Folder config file
469+[Dd]esktop.ini
470+
471+# Recycle Bin used on file shares
472+$RECYCLE.BIN/
473+
474+# Windows Installer files
475+*.cab
476+*.msi
477+*.msix
478+*.msm
479+*.msp
480+
481+# Windows shortcuts
482+*.lnk
483+
484+# Vim temporary swap files
485+*.swp
+82,
-0
1@@ -0,0 +1,82 @@
2+const string BASE_URL = "http://localhost:5143";
3+
4+var builder = WebApplication.CreateBuilder(args);
5+
6+// Add services to the container.
7+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
8+builder.Services.AddEndpointsApiExplorer();
9+builder.Services.AddSwaggerGen();
10+builder.Services.AddCors(options => {
11+ options.AddDefaultPolicy(policy => {
12+ policy.AllowAnyOrigin();
13+ policy.AllowAnyMethod();
14+ policy.AllowAnyHeader();
15+ });
16+});
17+
18+var app = builder.Build();
19+
20+// Configure the HTTP request pipeline.
21+if (app.Environment.IsDevelopment())
22+{
23+ app.UseSwagger();
24+ app.UseSwaggerUI();
25+}
26+
27+app.UseCors();
28+
29+var repo = new TodoRepo();
30+
31+app.MapGet("/", () =>
32+{
33+ return repo.All().Select(x => MapTodo(x));
34+})
35+.WithName("GetTodos")
36+.WithOpenApi();
37+
38+app.MapGet("/{id}", (Guid id) =>
39+{
40+ return MapTodo(repo.Find(id));
41+})
42+.WithName("GetTodo")
43+.WithOpenApi();
44+
45+app.MapPost("/", (Todo todo) =>
46+{
47+ return MapTodo(repo.Add(todo));
48+})
49+.WithName("CreateTodo")
50+.WithOpenApi();
51+
52+app.MapDelete("/", () => {
53+ repo.Clear();
54+})
55+.WithName("DeleteTodos")
56+.WithOpenApi();
57+
58+app.MapPatch("/{id}", (Guid id, ApiTodo todo) =>
59+{
60+ return MapTodo(repo.Update(id, todo.Title, todo.Order, todo.Completed));
61+})
62+.WithName("UpdateTodo")
63+.WithOpenApi();
64+
65+app.MapDelete("/{id}", (Guid id) => {
66+ repo.Delete(id);
67+})
68+.WithName("DeleteTodo")
69+.WithOpenApi();
70+
71+app.Run(BASE_URL);
72+
73+ApiTodo MapTodo(Todo todo) {
74+ return new(
75+ todo.Order,
76+ todo.Title,
77+ todo.Completed,
78+ $"{BASE_URL}/{todo.Id}"
79+ );
80+}
81+
82+public record ApiTodo(int? Order, string? Title, bool? Completed, string Url);
83+
1@@ -0,0 +1,41 @@
2+{
3+ "$schema": "http://json.schemastore.org/launchsettings.json",
4+ "iisSettings": {
5+ "windowsAuthentication": false,
6+ "anonymousAuthentication": true,
7+ "iisExpress": {
8+ "applicationUrl": "http://localhost:36722",
9+ "sslPort": 44305
10+ }
11+ },
12+ "profiles": {
13+ "http": {
14+ "commandName": "Project",
15+ "dotnetRunMessages": true,
16+ "launchBrowser": true,
17+ "launchUrl": "swagger",
18+ "applicationUrl": "http://localhost:5143",
19+ "environmentVariables": {
20+ "ASPNETCORE_ENVIRONMENT": "Development"
21+ }
22+ },
23+ "https": {
24+ "commandName": "Project",
25+ "dotnetRunMessages": true,
26+ "launchBrowser": true,
27+ "launchUrl": "swagger",
28+ "applicationUrl": "https://localhost:7104;http://localhost:5143",
29+ "environmentVariables": {
30+ "ASPNETCORE_ENVIRONMENT": "Development"
31+ }
32+ },
33+ "IIS Express": {
34+ "commandName": "IISExpress",
35+ "launchBrowser": true,
36+ "launchUrl": "swagger",
37+ "environmentVariables": {
38+ "ASPNETCORE_ENVIRONMENT": "Development"
39+ }
40+ }
41+ }
42+}
1@@ -0,0 +1,15 @@
2+<Project Sdk="Microsoft.NET.Sdk.Web">
3+
4+ <PropertyGroup>
5+ <TargetFramework>net8.0</TargetFramework>
6+ <Nullable>enable</Nullable>
7+ <ImplicitUsings>enable</ImplicitUsings>
8+ <InvariantGlobalization>true</InvariantGlobalization>
9+ </PropertyGroup>
10+
11+ <ItemGroup>
12+ <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1" />
13+ <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
14+ </ItemGroup>
15+
16+</Project>
1@@ -0,0 +1,6 @@
2+@TodoMinimal.WebApi_HostAddress = http://localhost:5143
3+
4+GET {{TodoMinimal.WebApi_HostAddress}}/weatherforecast/
5+Accept: application/json
6+
7+###
+40,
-0
1@@ -0,0 +1,40 @@
2+public record Todo(Guid Id, int Order, string Title, bool Completed = false);
3+
4+public class TodoRepo {
5+ private List<Todo> todos = new();
6+
7+ public Todo Add(Todo todo) {
8+ var newTodo = todo with { Id = Guid.NewGuid() };
9+ todos.Add(newTodo);
10+ return newTodo;
11+ }
12+
13+ public IEnumerable<Todo> All() {
14+ return todos;
15+ }
16+
17+ public void Clear() {
18+ todos.Clear();
19+ }
20+
21+ public Todo Find(Guid id) {
22+ return todos.Single(x => x.Id == id);
23+ }
24+
25+ public Todo Update(Guid id, string? title, int? order, bool? completed) {
26+ var todoIndex = todos.FindIndex(x => x.Id == id);
27+ var oldTodo = todos[todoIndex];
28+ var newTodo = oldTodo with {
29+ Title = title ?? oldTodo.Title,
30+ Order = order ?? oldTodo.Order,
31+ Completed = completed ?? oldTodo.Completed
32+ };
33+ todos[todoIndex] = newTodo;
34+ return newTodo;
35+ }
36+
37+ public void Delete(Guid id) {
38+ var todoIndex = todos.FindIndex(x => x.Id == id);
39+ todos.RemoveAt(todoIndex);
40+ }
41+}
1@@ -0,0 +1,8 @@
2+{
3+ "Logging": {
4+ "LogLevel": {
5+ "Default": "Information",
6+ "Microsoft.AspNetCore": "Warning"
7+ }
8+ }
9+}
+9,
-0
1@@ -0,0 +1,9 @@
2+{
3+ "Logging": {
4+ "LogLevel": {
5+ "Default": "Information",
6+ "Microsoft.AspNetCore": "Warning"
7+ }
8+ },
9+ "AllowedHosts": "*"
10+}
+22,
-0
1@@ -0,0 +1,22 @@
2+
3+Microsoft Visual Studio Solution File, Format Version 12.00
4+# Visual Studio Version 17
5+VisualStudioVersion = 17.0.31903.59
6+MinimumVisualStudioVersion = 10.0.40219.1
7+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoMinimal.WebApi", "TodoMinimal.WebApi\TodoMinimal.WebApi.csproj", "{C654AD60-A599-4CE9-B526-D60BCC58FC30}"
8+EndProject
9+Global
10+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
11+ Debug|Any CPU = Debug|Any CPU
12+ Release|Any CPU = Release|Any CPU
13+ EndGlobalSection
14+ GlobalSection(SolutionProperties) = preSolution
15+ HideSolutionNode = FALSE
16+ EndGlobalSection
17+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+ {C654AD60-A599-4CE9-B526-D60BCC58FC30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+ {C654AD60-A599-4CE9-B526-D60BCC58FC30}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+ {C654AD60-A599-4CE9-B526-D60BCC58FC30}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+ {C654AD60-A599-4CE9-B526-D60BCC58FC30}.Release|Any CPU.Build.0 = Release|Any CPU
22+ EndGlobalSection
23+EndGlobal