Migrate API to .NET Core 3.0 (#31)

Migrate API to .NET Core 3.0 (fixes #30)
This commit is contained in:
Daniel J. Summers 2019-09-28 08:42:58 -05:00 committed by GitHub
parent ac8b39fff9
commit 715df08cbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 7 deletions

View File

@ -86,6 +86,15 @@ module private Helpers =
let asJson<'T> next ctx (o : 'T) =
json o next ctx
/// Work-around to let the Json.NET serializer synchronously deserialize from the request stream
// TODO: Remove this once there is an async serializer
let allowSyncIO : HttpHandler =
fun next ctx ->
match ctx.Features.Get<Features.IHttpBodyControlFeature>() with
| null -> ()
| f -> f.AllowSynchronousIO <- true
next ctx
/// Strongly-typed models for post requests
module Models =
@ -156,6 +165,7 @@ module Request =
/// POST /api/request
let add : HttpHandler =
authorize
>=> allowSyncIO
>=> fun next ctx ->
task {
let! r = ctx.BindJsonAsync<Models.Request> ()
@ -187,6 +197,7 @@ module Request =
/// POST /api/request/[req-id]/history
let addHistory requestId : HttpHandler =
authorize
>=> allowSyncIO
>=> fun next ctx ->
task {
use sess = session ctx
@ -218,6 +229,7 @@ module Request =
/// POST /api/request/[req-id]/note
let addNote requestId : HttpHandler =
authorize
>=> allowSyncIO
>=> fun next ctx ->
task {
use sess = session ctx
@ -297,6 +309,7 @@ module Request =
/// PATCH /api/request/[req-id]/snooze
let snooze requestId : HttpHandler =
authorize
>=> allowSyncIO
>=> fun next ctx ->
task {
use sess = session ctx
@ -314,6 +327,7 @@ module Request =
/// PATCH /api/request/[req-id]/recurrence
let updateRecurrence requestId : HttpHandler =
authorize
>=> allowSyncIO
>=> fun next ctx ->
task {
use sess = session ctx

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>2.0.1.0</Version>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Version>2.1.0.0</Version>
</PropertyGroup>
<ItemGroup>
@ -16,7 +16,7 @@
<PackageReference Include="FunctionalCuid" Version="1.0.0" />
<PackageReference Include="Giraffe" Version="3.6.0" />
<PackageReference Include="Giraffe.TokenRouter" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
<PackageReference Include="Microsoft.FSharpLu" Version="0.10.29" />
<PackageReference Include="Microsoft.FSharpLu.Json" Version="0.10.29" />
<PackageReference Include="RavenDb.Client" Version="4.2.1" />

View File

@ -90,11 +90,12 @@ module Configure =
bldr.ConfigureServices svcs
open Microsoft.Extensions.Logging
open Microsoft.Extensions.Hosting
/// Configure logging
let logging (bldr : IWebHostBuilder) =
let logz (log : ILoggingBuilder) =
let env = log.Services.BuildServiceProvider().GetService<IHostingEnvironment> ()
let env = log.Services.BuildServiceProvider().GetService<IWebHostEnvironment> ()
match env.IsDevelopment () with
| true -> log
| false -> log.AddFilter(fun l -> l > LogLevel.Information)
@ -109,7 +110,7 @@ module Configure =
let appConfig =
Action<IApplicationBuilder> (
fun (app : IApplicationBuilder) ->
let env = app.ApplicationServices.GetService<IHostingEnvironment> ()
let env = app.ApplicationServices.GetService<IWebHostEnvironment> ()
match env.IsDevelopment () with
| true -> app.UseDeveloperExceptionPage ()
| false -> app.UseGiraffeErrorHandler Handlers.Error.error

View File

@ -1,6 +1,6 @@
{
"name": "my-prayer-journal",
"version": "2.0.1",
"version": "2.1.0",
"description": "myPrayerJournal - Front End",
"author": "Daniel J. Summers <daniel@bitbadger.solutions>",
"private": true,
@ -10,7 +10,7 @@
"lint": "vue-cli-service lint",
"apistart": "cd ../MyPrayerJournal.Api && dotnet run",
"vue": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet run",
"publish": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet publish -c Release"
"publish": "vue-cli-service build --modern && cd ../MyPrayerJournal.Api && dotnet publish -c Release -r linux-x64 --self-contained false"
},
"dependencies": {
"auth0-js": "^9.7.3",