From cd2dbd6eeebb6b93a9ecd4fd465b3fe3a7e799a8 Mon Sep 17 00:00:00 2001 From: Sindre Kjelsrud Date: Wed, 13 Sep 2023 09:35:02 +0200 Subject: [PATCH 1/3] :see_no_evil: update gitignore for backend Co-authored-by: haraldnilsen --- .gitignore | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/.gitignore b/.gitignore index ac0ae0c..5f96e78 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,138 @@ dist-ssr *.njsproj *.sln *.sw? + +# copypasta from gitignore for c# +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.svclog +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.azurePubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +packages/ +## TODO: If the tool you use requires repositories.config, also uncomment the next line +!packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +![Ss]tyle[Cc]op.targets +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml + +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +_NCrunch* \ No newline at end of file From a260cb63b74e097374becec26b6ba488ba263b72 Mon Sep 17 00:00:00 2001 From: Sindre Kjelsrud Date: Wed, 13 Sep 2023 09:37:55 +0200 Subject: [PATCH 2/3] :bricks: added backend Co-authored-by: haraldnilsen --- backend/Program.cs | 2 ++ backend/backend.csproj | 10 ++++++++++ .eslintrc.cjs => frontend/.eslintrc.cjs | 0 .prettierrc.json => frontend/.prettierrc.json | 0 index.html => frontend/index.html | 0 package.json => frontend/package.json | 0 postcss.config.js => frontend/postcss.config.js | 0 .../public}/arrow-down-up-svgrepo-com.svg | 8 ++++---- {public => frontend/public}/vite.svg | 0 {src => frontend/src}/App.css | 0 {src => frontend/src}/App.tsx | 0 {src => frontend/src}/api/fetchMovie.ts | 0 {src => frontend/src}/assets/react.svg | 0 {src => frontend/src}/components/MovieForm/index.tsx | 0 {src => frontend/src}/components/MovieModal/index.tsx | 0 {src => frontend/src}/components/MovieTable/index.tsx | 0 .../src}/components/MovieTableRow/index.tsx | 0 {src => frontend/src}/components/Pagination/index.tsx | 0 {src => frontend/src}/components/Pagination/styles.css | 0 .../src}/components/PaginationButton/index.tsx | 0 .../src}/components/PaginationButton/styles.css | 0 {src => frontend/src}/components/index.ts | 0 {src => frontend/src}/main.tsx | 0 {src => frontend/src}/types/movie.ts | 0 {src => frontend/src}/vite-env.d.ts | 0 tailwind.config.js => frontend/tailwind.config.js | 0 tsconfig.json => frontend/tsconfig.json | 0 tsconfig.node.json => frontend/tsconfig.node.json | 0 vite.config.ts => frontend/vite.config.ts | 0 29 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 backend/Program.cs create mode 100644 backend/backend.csproj rename .eslintrc.cjs => frontend/.eslintrc.cjs (100%) rename .prettierrc.json => frontend/.prettierrc.json (100%) rename index.html => frontend/index.html (100%) rename package.json => frontend/package.json (100%) rename postcss.config.js => frontend/postcss.config.js (100%) rename {public => frontend/public}/arrow-down-up-svgrepo-com.svg (99%) rename {public => frontend/public}/vite.svg (100%) rename {src => frontend/src}/App.css (100%) rename {src => frontend/src}/App.tsx (100%) rename {src => frontend/src}/api/fetchMovie.ts (100%) rename {src => frontend/src}/assets/react.svg (100%) rename {src => frontend/src}/components/MovieForm/index.tsx (100%) rename {src => frontend/src}/components/MovieModal/index.tsx (100%) rename {src => frontend/src}/components/MovieTable/index.tsx (100%) rename {src => frontend/src}/components/MovieTableRow/index.tsx (100%) rename {src => frontend/src}/components/Pagination/index.tsx (100%) rename {src => frontend/src}/components/Pagination/styles.css (100%) rename {src => frontend/src}/components/PaginationButton/index.tsx (100%) rename {src => frontend/src}/components/PaginationButton/styles.css (100%) rename {src => frontend/src}/components/index.ts (100%) rename {src => frontend/src}/main.tsx (100%) rename {src => frontend/src}/types/movie.ts (100%) rename {src => frontend/src}/vite-env.d.ts (100%) rename tailwind.config.js => frontend/tailwind.config.js (100%) rename tsconfig.json => frontend/tsconfig.json (100%) rename tsconfig.node.json => frontend/tsconfig.node.json (100%) rename vite.config.ts => frontend/vite.config.ts (100%) diff --git a/backend/Program.cs b/backend/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/backend/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/backend/backend.csproj b/backend/backend.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/backend/backend.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/.eslintrc.cjs b/frontend/.eslintrc.cjs similarity index 100% rename from .eslintrc.cjs rename to frontend/.eslintrc.cjs diff --git a/.prettierrc.json b/frontend/.prettierrc.json similarity index 100% rename from .prettierrc.json rename to frontend/.prettierrc.json diff --git a/index.html b/frontend/index.html similarity index 100% rename from index.html rename to frontend/index.html diff --git a/package.json b/frontend/package.json similarity index 100% rename from package.json rename to frontend/package.json diff --git a/postcss.config.js b/frontend/postcss.config.js similarity index 100% rename from postcss.config.js rename to frontend/postcss.config.js diff --git a/public/arrow-down-up-svgrepo-com.svg b/frontend/public/arrow-down-up-svgrepo-com.svg similarity index 99% rename from public/arrow-down-up-svgrepo-com.svg rename to frontend/public/arrow-down-up-svgrepo-com.svg index 4664f59..cf34872 100644 --- a/public/arrow-down-up-svgrepo-com.svg +++ b/frontend/public/arrow-down-up-svgrepo-com.svg @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/public/vite.svg b/frontend/public/vite.svg similarity index 100% rename from public/vite.svg rename to frontend/public/vite.svg diff --git a/src/App.css b/frontend/src/App.css similarity index 100% rename from src/App.css rename to frontend/src/App.css diff --git a/src/App.tsx b/frontend/src/App.tsx similarity index 100% rename from src/App.tsx rename to frontend/src/App.tsx diff --git a/src/api/fetchMovie.ts b/frontend/src/api/fetchMovie.ts similarity index 100% rename from src/api/fetchMovie.ts rename to frontend/src/api/fetchMovie.ts diff --git a/src/assets/react.svg b/frontend/src/assets/react.svg similarity index 100% rename from src/assets/react.svg rename to frontend/src/assets/react.svg diff --git a/src/components/MovieForm/index.tsx b/frontend/src/components/MovieForm/index.tsx similarity index 100% rename from src/components/MovieForm/index.tsx rename to frontend/src/components/MovieForm/index.tsx diff --git a/src/components/MovieModal/index.tsx b/frontend/src/components/MovieModal/index.tsx similarity index 100% rename from src/components/MovieModal/index.tsx rename to frontend/src/components/MovieModal/index.tsx diff --git a/src/components/MovieTable/index.tsx b/frontend/src/components/MovieTable/index.tsx similarity index 100% rename from src/components/MovieTable/index.tsx rename to frontend/src/components/MovieTable/index.tsx diff --git a/src/components/MovieTableRow/index.tsx b/frontend/src/components/MovieTableRow/index.tsx similarity index 100% rename from src/components/MovieTableRow/index.tsx rename to frontend/src/components/MovieTableRow/index.tsx diff --git a/src/components/Pagination/index.tsx b/frontend/src/components/Pagination/index.tsx similarity index 100% rename from src/components/Pagination/index.tsx rename to frontend/src/components/Pagination/index.tsx diff --git a/src/components/Pagination/styles.css b/frontend/src/components/Pagination/styles.css similarity index 100% rename from src/components/Pagination/styles.css rename to frontend/src/components/Pagination/styles.css diff --git a/src/components/PaginationButton/index.tsx b/frontend/src/components/PaginationButton/index.tsx similarity index 100% rename from src/components/PaginationButton/index.tsx rename to frontend/src/components/PaginationButton/index.tsx diff --git a/src/components/PaginationButton/styles.css b/frontend/src/components/PaginationButton/styles.css similarity index 100% rename from src/components/PaginationButton/styles.css rename to frontend/src/components/PaginationButton/styles.css diff --git a/src/components/index.ts b/frontend/src/components/index.ts similarity index 100% rename from src/components/index.ts rename to frontend/src/components/index.ts diff --git a/src/main.tsx b/frontend/src/main.tsx similarity index 100% rename from src/main.tsx rename to frontend/src/main.tsx diff --git a/src/types/movie.ts b/frontend/src/types/movie.ts similarity index 100% rename from src/types/movie.ts rename to frontend/src/types/movie.ts diff --git a/src/vite-env.d.ts b/frontend/src/vite-env.d.ts similarity index 100% rename from src/vite-env.d.ts rename to frontend/src/vite-env.d.ts diff --git a/tailwind.config.js b/frontend/tailwind.config.js similarity index 100% rename from tailwind.config.js rename to frontend/tailwind.config.js diff --git a/tsconfig.json b/frontend/tsconfig.json similarity index 100% rename from tsconfig.json rename to frontend/tsconfig.json diff --git a/tsconfig.node.json b/frontend/tsconfig.node.json similarity index 100% rename from tsconfig.node.json rename to frontend/tsconfig.node.json diff --git a/vite.config.ts b/frontend/vite.config.ts similarity index 100% rename from vite.config.ts rename to frontend/vite.config.ts From 040c416f14d6717adf92952d2b751b21eb69d3de Mon Sep 17 00:00:00 2001 From: Sindre Kjelsrud Date: Wed, 13 Sep 2023 10:37:53 +0200 Subject: [PATCH 3/3] :bricks: added new template for api-endpoint Co-authored-by: haraldnilsen --- .../Controllers/WeatherForecastController.cs | 32 +++++++++++++++ backend/Program.cs | 27 +++++++++++- backend/Properties/launchSettings.json | 41 +++++++++++++++++++ backend/WeatherForecast.cs | 12 ++++++ backend/appsettings.Development.json | 8 ++++ backend/appsettings.json | 9 ++++ backend/backend.csproj | 10 +++-- 7 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 backend/Controllers/WeatherForecastController.cs create mode 100644 backend/Properties/launchSettings.json create mode 100644 backend/WeatherForecast.cs create mode 100644 backend/appsettings.Development.json create mode 100644 backend/appsettings.json diff --git a/backend/Controllers/WeatherForecastController.cs b/backend/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..44d1739 --- /dev/null +++ b/backend/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace backend.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController : ControllerBase +{ + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } +} diff --git a/backend/Program.cs b/backend/Program.cs index 3751555..48863a6 100644 --- a/backend/Program.cs +++ b/backend/Program.cs @@ -1,2 +1,25 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/backend/Properties/launchSettings.json b/backend/Properties/launchSettings.json new file mode 100644 index 0000000..b8bebeb --- /dev/null +++ b/backend/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:17138", + "sslPort": 44374 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5212", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7235;http://localhost:5212", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/backend/WeatherForecast.cs b/backend/WeatherForecast.cs new file mode 100644 index 0000000..1e490be --- /dev/null +++ b/backend/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace backend; + +public class WeatherForecast +{ + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } +} diff --git a/backend/appsettings.Development.json b/backend/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/backend/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/backend/appsettings.json b/backend/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/backend/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/backend/backend.csproj b/backend/backend.csproj index f02677b..d2f5cb0 100644 --- a/backend/backend.csproj +++ b/backend/backend.csproj @@ -1,10 +1,14 @@ - + - Exe net7.0 - enable enable + enable + + + + +