Add F# api project
This commit is contained in:
parent
437112d7ac
commit
286bc86e3e
38
api/Controllers/WeatherForecastController.fs
Normal file
38
api/Controllers/WeatherForecastController.fs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
namespace api.Controllers
|
||||||
|
|
||||||
|
open System
|
||||||
|
open System.Collections.Generic
|
||||||
|
open System.Linq
|
||||||
|
open System.Threading.Tasks
|
||||||
|
open Microsoft.AspNetCore.Mvc
|
||||||
|
open Microsoft.Extensions.Logging
|
||||||
|
open api
|
||||||
|
|
||||||
|
[<ApiController>]
|
||||||
|
[<Route("[controller]")>]
|
||||||
|
type WeatherForecastController (logger : ILogger<WeatherForecastController>) =
|
||||||
|
inherit ControllerBase()
|
||||||
|
|
||||||
|
let summaries =
|
||||||
|
[|
|
||||||
|
"Freezing"
|
||||||
|
"Bracing"
|
||||||
|
"Chilly"
|
||||||
|
"Cool"
|
||||||
|
"Mild"
|
||||||
|
"Warm"
|
||||||
|
"Balmy"
|
||||||
|
"Hot"
|
||||||
|
"Sweltering"
|
||||||
|
"Scorching"
|
||||||
|
|]
|
||||||
|
|
||||||
|
[<HttpGet>]
|
||||||
|
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)] }
|
||||||
|
|]
|
||||||
36
api/Program.fs
Normal file
36
api/Program.fs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace api
|
||||||
|
#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
|
||||||
|
|
||||||
|
[<EntryPoint>]
|
||||||
|
let main args =
|
||||||
|
|
||||||
|
let builder = WebApplication.CreateBuilder(args)
|
||||||
|
|
||||||
|
builder.Services.AddControllers()
|
||||||
|
|
||||||
|
let app = builder.Build()
|
||||||
|
|
||||||
|
app.UseHttpsRedirection()
|
||||||
|
|
||||||
|
app.UseAuthorization()
|
||||||
|
app.MapControllers()
|
||||||
|
|
||||||
|
app.Run()
|
||||||
|
|
||||||
|
exitCode
|
||||||
31
api/Properties/launchSettings.json
Normal file
31
api/Properties/launchSettings.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:22555",
|
||||||
|
"sslPort": 44395
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"api": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "weatherforecast",
|
||||||
|
"applicationUrl": "https://localhost:7115;http://localhost:5217",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "weatherforecast",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
api/WeatherForecast.fs
Normal file
11
api/WeatherForecast.fs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace api
|
||||||
|
|
||||||
|
open System
|
||||||
|
|
||||||
|
type WeatherForecast =
|
||||||
|
{ Date: DateTime
|
||||||
|
TemperatureC: int
|
||||||
|
Summary: string }
|
||||||
|
|
||||||
|
member this.TemperatureF =
|
||||||
|
32.0 + (float this.TemperatureC / 0.5556)
|
||||||
13
api/api.fsproj
Normal file
13
api/api.fsproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="WeatherForecast.fs" />
|
||||||
|
<Compile Include="Controllers/WeatherForecastController.fs" />
|
||||||
|
<Compile Include="Program.fs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
8
api/appsettings.Development.json
Normal file
8
api/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
api/appsettings.json
Normal file
9
api/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
66
api/obj/api.fsproj.nuget.dgspec.json
Normal file
66
api/obj/api.fsproj.nuget.dgspec.json
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"format": 1,
|
||||||
|
"restore": {
|
||||||
|
"/home/kevin/projects/websites/portfolio/api/api.fsproj": {}
|
||||||
|
},
|
||||||
|
"projects": {
|
||||||
|
"/home/kevin/projects/websites/portfolio/api/api.fsproj": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/home/kevin/projects/websites/portfolio/api/api.fsproj",
|
||||||
|
"projectName": "api",
|
||||||
|
"projectPath": "/home/kevin/projects/websites/portfolio/api/api.fsproj",
|
||||||
|
"packagesPath": "/home/kevin/.nuget/packages/",
|
||||||
|
"outputPath": "/home/kevin/projects/websites/portfolio/api/obj/",
|
||||||
|
"projectStyle": "PackageReference",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/home/kevin/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"originalTargetFrameworks": [
|
||||||
|
"net6.0"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"projectReferences": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"dependencies": {
|
||||||
|
"FSharp.Core": {
|
||||||
|
"include": "Runtime, Compile, Build, Native, Analyzers, BuildTransitive",
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[6.0.1, )",
|
||||||
|
"generatePathProperty": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imports": [
|
||||||
|
"net461",
|
||||||
|
"net462",
|
||||||
|
"net47",
|
||||||
|
"net471",
|
||||||
|
"net472",
|
||||||
|
"net48"
|
||||||
|
],
|
||||||
|
"assetTargetFallback": true,
|
||||||
|
"warn": true,
|
||||||
|
"frameworkReferences": {
|
||||||
|
"Microsoft.AspNetCore.App": {
|
||||||
|
"privateAssets": "none"
|
||||||
|
},
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"privateAssets": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimeIdentifierGraphPath": "/usr/lib/dotnet/sdk/6.0.116/RuntimeIdentifierGraph.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
api/obj/api.fsproj.nuget.g.props
Normal file
18
api/obj/api.fsproj.nuget.g.props
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||||
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/kevin/.nuget/packages/</NuGetPackageRoot>
|
||||||
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/kevin/.nuget/packages/</NuGetPackageFolders>
|
||||||
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.0.4</NuGetToolVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<SourceRoot Include="/home/kevin/.nuget/packages/" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<PkgFSharp_Core Condition=" '$(PkgFSharp_Core)' == '' ">/home/kevin/.nuget/packages/fsharp.core/6.0.1</PkgFSharp_Core>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
2
api/obj/api.fsproj.nuget.g.targets
Normal file
2
api/obj/api.fsproj.nuget.g.targets
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
||||||
176
api/obj/project.assets.json
Normal file
176
api/obj/project.assets.json
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"targets": {
|
||||||
|
"net6.0": {
|
||||||
|
"FSharp.Core/6.0.1": {
|
||||||
|
"type": "package",
|
||||||
|
"compile": {
|
||||||
|
"lib/netstandard2.1/FSharp.Core.dll": {}
|
||||||
|
},
|
||||||
|
"runtime": {
|
||||||
|
"lib/netstandard2.1/FSharp.Core.dll": {}
|
||||||
|
},
|
||||||
|
"resource": {
|
||||||
|
"lib/netstandard2.1/cs/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "cs"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/de/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "de"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/es/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "es"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/fr/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "fr"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/it/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "it"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/ja/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "ja"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/ko/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "ko"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/pl/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "pl"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/pt-BR/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "pt-BR"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/ru/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "ru"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/tr/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "tr"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/zh-Hans/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "zh-Hans"
|
||||||
|
},
|
||||||
|
"lib/netstandard2.1/zh-Hant/FSharp.Core.resources.dll": {
|
||||||
|
"locale": "zh-Hant"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contentFiles": {
|
||||||
|
"contentFiles/any/any/_._": {
|
||||||
|
"buildAction": "None",
|
||||||
|
"codeLanguage": "any",
|
||||||
|
"copyToOutput": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libraries": {
|
||||||
|
"FSharp.Core/6.0.1": {
|
||||||
|
"sha512": "VrFAiW8dEEekk+0aqlbvMNZzDvYXmgWZwAt68AUBqaWK8RnoEVUNglj66bZzhs4/U63q0EfXlhcEKnH1sTYLjw==",
|
||||||
|
"type": "package",
|
||||||
|
"path": "fsharp.core/6.0.1",
|
||||||
|
"files": [
|
||||||
|
".nupkg.metadata",
|
||||||
|
".signature.p7s",
|
||||||
|
"Icon.png",
|
||||||
|
"contentFiles/any/netstandard2.0/FSharp.Core.xml",
|
||||||
|
"contentFiles/any/netstandard2.1/FSharp.Core.xml",
|
||||||
|
"fsharp.core.6.0.1.nupkg.sha512",
|
||||||
|
"fsharp.core.nuspec",
|
||||||
|
"lib/netstandard2.0/FSharp.Core.dll",
|
||||||
|
"lib/netstandard2.0/FSharp.Core.xml",
|
||||||
|
"lib/netstandard2.0/cs/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/de/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/es/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/fr/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/it/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/ja/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/ko/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/pl/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/pt-BR/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/ru/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/tr/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/zh-Hans/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.0/zh-Hant/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/FSharp.Core.dll",
|
||||||
|
"lib/netstandard2.1/FSharp.Core.xml",
|
||||||
|
"lib/netstandard2.1/cs/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/de/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/es/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/fr/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/it/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/ja/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/ko/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/pl/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/pt-BR/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/ru/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/tr/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/zh-Hans/FSharp.Core.resources.dll",
|
||||||
|
"lib/netstandard2.1/zh-Hant/FSharp.Core.resources.dll"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"projectFileDependencyGroups": {
|
||||||
|
"net6.0": [
|
||||||
|
"FSharp.Core >= 6.0.1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"packageFolders": {
|
||||||
|
"/home/kevin/.nuget/packages/": {}
|
||||||
|
},
|
||||||
|
"project": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"restore": {
|
||||||
|
"projectUniqueName": "/home/kevin/projects/websites/portfolio/api/api.fsproj",
|
||||||
|
"projectName": "api",
|
||||||
|
"projectPath": "/home/kevin/projects/websites/portfolio/api/api.fsproj",
|
||||||
|
"packagesPath": "/home/kevin/.nuget/packages/",
|
||||||
|
"outputPath": "/home/kevin/projects/websites/portfolio/api/obj/",
|
||||||
|
"projectStyle": "PackageReference",
|
||||||
|
"configFilePaths": [
|
||||||
|
"/home/kevin/.nuget/NuGet/NuGet.Config"
|
||||||
|
],
|
||||||
|
"originalTargetFrameworks": [
|
||||||
|
"net6.0"
|
||||||
|
],
|
||||||
|
"sources": {
|
||||||
|
"https://api.nuget.org/v3/index.json": {}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"projectReferences": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net6.0": {
|
||||||
|
"targetAlias": "net6.0",
|
||||||
|
"dependencies": {
|
||||||
|
"FSharp.Core": {
|
||||||
|
"include": "Runtime, Compile, Build, Native, Analyzers, BuildTransitive",
|
||||||
|
"target": "Package",
|
||||||
|
"version": "[6.0.1, )",
|
||||||
|
"generatePathProperty": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imports": [
|
||||||
|
"net461",
|
||||||
|
"net462",
|
||||||
|
"net47",
|
||||||
|
"net471",
|
||||||
|
"net472",
|
||||||
|
"net48"
|
||||||
|
],
|
||||||
|
"assetTargetFallback": true,
|
||||||
|
"warn": true,
|
||||||
|
"frameworkReferences": {
|
||||||
|
"Microsoft.AspNetCore.App": {
|
||||||
|
"privateAssets": "none"
|
||||||
|
},
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"privateAssets": "all"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimeIdentifierGraphPath": "/usr/lib/dotnet/sdk/6.0.116/RuntimeIdentifierGraph.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
api/obj/project.nuget.cache
Normal file
10
api/obj/project.nuget.cache
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"dgSpecHash": "yiQsN9zuNFsQwE5rD1bvmKb2LkPUxTBStlenUjE5prfHVEsOWqez5UPTlQ2uPwnzMX+/02Z8m43BzcokYS9hFg==",
|
||||||
|
"success": true,
|
||||||
|
"projectFilePath": "/home/kevin/projects/websites/portfolio/api/api.fsproj",
|
||||||
|
"expectedPackageFiles": [
|
||||||
|
"/home/kevin/.nuget/packages/fsharp.core/6.0.1/fsharp.core.6.0.1.nupkg.sha512"
|
||||||
|
],
|
||||||
|
"logs": []
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user