forked from Badgerati/Pode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure ErrorLoggingLevels is only set when ErrorLoggingEnabled is tru…
…e in Pode listener configuration. Include Badgerati#1507 fixes
- Loading branch information
Showing
10 changed files
with
152 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
try { | ||
# Determine the script path and Pode module path | ||
$ScriptPath = (Split-Path -Parent -Path $MyInvocation.MyCommand.Path) | ||
$podePath = Split-Path -Parent -Path $ScriptPath | ||
|
||
# Import the Pode module from the source path if it exists, otherwise from installed modules | ||
if (Test-Path -Path "$($podePath)/src/Pode.psm1" -PathType Leaf) { | ||
Import-Module "$($podePath)/src/Pode.psm1" -Force -ErrorAction Stop | ||
} | ||
else { | ||
Import-Module -Name 'Pode' -MaximumVersion 2.99 -ErrorAction Stop | ||
} | ||
} | ||
catch { throw } | ||
|
||
Start-PodeServer -ScriptBlock { | ||
Add-PodeEndpoint -Address localhost -Port $Port -Protocol Http | ||
Add-PodeRoute -Method Get -Path '/close' -ScriptBlock { | ||
Close-PodeServer | ||
} | ||
|
||
Enable-PodeSessionMiddleware -Secret 'schwifty' -Duration 5 -Extend -UseHeaders | ||
|
||
New-PodeAuthScheme -Basic | Add-PodeAuth -Name 'Auth' -ScriptBlock { | ||
param($username, $password) | ||
|
||
if (($username -eq 'morty') -and ($password -eq 'pickle')) { | ||
return @{ User = @{ ID = 'M0R7Y302' } } | ||
} | ||
|
||
return @{ Message = 'Invalid details supplied' } | ||
} | ||
|
||
Add-PodeRoute -Method Post -Path '/auth/basic' -Authentication Auth -ScriptBlock { | ||
$WebEvent.Session.Data.Views++ | ||
|
||
Write-PodeJsonResponse -Value @{ | ||
Result = 'OK' | ||
Username = $WebEvent.Auth.User.ID | ||
Views = $WebEvent.Session.Data.Views | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters