Skip to content

Commit

Permalink
Move database initialization outside of service configuration in `Pro… (
Browse files Browse the repository at this point in the history
#67)

* Move database initialization outside of service configuration in `Program.fs`

* Update .NET version to 8.0.x in GitHub workflows
  • Loading branch information
swuecho authored Jan 30, 2025
1 parent 68283f5 commit 833f3b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
dotnet-version: "8.0.x"
- name: Restore dependencies
run: dotnet restore
working-directory: api
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: api
Expand Down
8 changes: 3 additions & 5 deletions api/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,16 @@ let authService (services: IServiceCollection) =

// let config = configuration [||] { add_env }

// init db
Database.InitDB.init Database.Config.connStr |> ignore

webHost [||] {
// Use the specified middleware if the provided predicate is "true".
use_if FalcoExtensions.IsDevelopment DeveloperExceptionPageExtensions.UseDeveloperExceptionPage

use_cors corsPolicyName corsOptions
add_service authService

// init db
add_service (fun services ->
Database.InitDB.init Database.Config.connStr |> ignore
services)

// Use authorization middleware. Call before any middleware that depends on users being authenticated.
// jwt decode add set context.User.Identity.IsAuthenticated true if user is valid
use_authentication
Expand Down

0 comments on commit 833f3b7

Please sign in to comment.