From b9f3fba383f374dddf86afa79c8d8bb5f97dcee4 Mon Sep 17 00:00:00 2001 From: Murtadha Date: Sat, 20 Jul 2024 15:36:00 -0400 Subject: [PATCH] v0.0.0 backend initial commit --- .gitignore | 116 ++++++++++++++++++++++++++++++++- Program.cs | 44 +++++++++++++ Properties/launchSettings.json | 41 ++++++++++++ appsettings.json | 9 +++ backend.csproj | 20 ++++++ backend.http | 6 ++ version.txt | 1 + 7 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 Program.cs create mode 100644 Properties/launchSettings.json create mode 100644 appsettings.json create mode 100644 backend.csproj create mode 100644 backend.http create mode 100644 version.txt diff --git a/.gitignore b/.gitignore index b512c09..c7edd36 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,115 @@ -node_modules \ No newline at end of file +# .NET Core +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio +.vs/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# User-specific files +*.rsuser + +# Mono auto generated files +mono_crash.* + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# Local appsettings +appsettings.Development.json +appsettings.Production.json + +# Sensitive or environment-specific config files +*.Development.json +*.Production.json +*.Staging.json + +# Ignore IDE-specific files +.vscode/ +.idea/ +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..fda9a7d --- /dev/null +++ b/Program.cs @@ -0,0 +1,44 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// 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(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +app.MapGet("/weatherforecast", () => +{ + var forecast = Enumerable.Range(1, 5).Select(index => + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) + .ToArray(); + return forecast; +}) +.WithName("GetWeatherForecast") +.WithOpenApi(); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..e2b6b57 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:65439", + "sslPort": 44367 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7195;http://localhost:5001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..4d56694 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/backend.csproj b/backend.csproj new file mode 100644 index 0000000..72a664f --- /dev/null +++ b/backend.csproj @@ -0,0 +1,20 @@ + + + + net8.0 + enable + enable + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + diff --git a/backend.http b/backend.http new file mode 100644 index 0000000..2f9a5e1 --- /dev/null +++ b/backend.http @@ -0,0 +1,6 @@ +@backend_HostAddress = http://localhost:5001 + +GET {{backend_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..bd52db8 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.0.0 \ No newline at end of file