diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6b4e4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +# Build results +bin/ +obj/ +out/ + +# .NET user-specific files +*.user +*.rsuser +*.suo +*.userosscache +*.sln.docstates + +# Rider +.idea/ +*.sln.iml + +# VS Code +.vscode/ + +# Visual Studio +.vs/ + +# Logs +*.log + +# OS files +.DS_Store +Thumbs.db + +# ASP.NET secrets +secrets.json + +# Publish output +publish/ + +# NuGet +*.nupkg +*.snupkg +.nuget/ +packages/ + +# Test results +TestResults/ +*.trx + +# Coverage +coverage/ +*.coverage +*.coveragexml + +# Temporary files +*.tmp +*.temp diff --git a/Controllers/WeatherForecastController.fs b/Controllers/WeatherForecastController.fs new file mode 100644 index 0000000..e5a28e8 --- /dev/null +++ b/Controllers/WeatherForecastController.fs @@ -0,0 +1,38 @@ +namespace MusicAPI.Controllers + +open System +open System.Collections.Generic +open System.Linq +open System.Threading.Tasks +open Microsoft.AspNetCore.Mvc +open Microsoft.Extensions.Logging +open MusicAPI + +[] +[] +type WeatherForecastController (logger : ILogger) = + inherit ControllerBase() + + let summaries = + [| + "Freezing" + "Bracing" + "Chilly" + "Cool" + "Mild" + "Warm" + "Balmy" + "Hot" + "Sweltering" + "Scorching" + |] + + [] + member _.Get() = + let rng = System.Random() + [| + for index in 0..4 -> + { Date = DateTime.Now.AddDays(float index) + TemperatureC = rng.Next(-20,55) + Summary = summaries.[rng.Next(summaries.Length)] } + |] diff --git a/MusicAPI.fsproj b/MusicAPI.fsproj new file mode 100644 index 0000000..b42e1e3 --- /dev/null +++ b/MusicAPI.fsproj @@ -0,0 +1,13 @@ + + + + net9.0 + + + + + + + + + diff --git a/Program.fs b/Program.fs new file mode 100644 index 0000000..04e10ae --- /dev/null +++ b/Program.fs @@ -0,0 +1,36 @@ +namespace MusicAPI +#nowarn "20" +open System +open System.Collections.Generic +open System.IO +open System.Linq +open System.Threading.Tasks +open Microsoft.AspNetCore +open Microsoft.AspNetCore.Builder +open Microsoft.AspNetCore.Hosting +open Microsoft.AspNetCore.HttpsPolicy +open Microsoft.Extensions.Configuration +open Microsoft.Extensions.DependencyInjection +open Microsoft.Extensions.Hosting +open Microsoft.Extensions.Logging + +module Program = + let exitCode = 0 + + [] + let main args = + + let builder = WebApplication.CreateBuilder(args) + + builder.Services.AddControllers() + + let app = builder.Build() + + app.UseHttpsRedirection() + + app.UseAuthorization() + app.MapControllers() + + app.Run() + + exitCode diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..88ea86e --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "http://localhost:5006", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "https://localhost:7072;http://localhost:5006", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/README.md b/README.md index 650f8e3..dad5879 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # MusicAPI -F# music API for offline server. \ No newline at end of file +## .NET commands + +initialize project: +* `dotnet new webapi -lang F# -o MusicAPI` + +run project locally: +* `dotnet run` + +## Deployment diff --git a/WeatherForecast.fs b/WeatherForecast.fs new file mode 100644 index 0000000..5aa44fb --- /dev/null +++ b/WeatherForecast.fs @@ -0,0 +1,11 @@ +namespace MusicAPI + +open System + +type WeatherForecast = + { Date: DateTime + TemperatureC: int + Summary: string } + + member this.TemperatureF = + 32.0 + (float this.TemperatureC / 0.5556) diff --git a/appsettings.Development.json b/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}