Badgerati / Pode

Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
https://badgerati.github.io/Pode
MIT License
830 stars 92 forks source link

Pode Configuration Functions (idea not ready yet) #1336

Closed mdaneri closed 4 days ago

mdaneri commented 2 months ago

Summary

This document provides details on two new functions, Set-PodeConfiguration and Get-PodeConfiguration, to manage Pode server configurations programmatically.

Functions

Set-PodeConfiguration

This function allows users to set various configurations for the Pode server as an alternative to using the server.psd1 file or directly modifying the $PodeContext hashtable.

Parameters

Examples

Set-PodeConfiguration -SslProtocols @('TLS12', 'TLS13')
Set-PodeConfiguration -RequestTimeout 300 -RequestBodySize 1048576
Set-PodeConfiguration -DisableAutoImportModules -AutoImportModulesExportOnly
Set-PodeConfiguration -RestartPeriod 360
Set-PodeConfiguration -RestartCrons @('0 12 * * TUE,FRI')
Set-PodeConfiguration -RestartTimes @('09:45', '21:15')
Set-PodeConfiguration -FileMonitorEnable -FileMonitorInclude @('*.txt', '*.ps1') -FileMonitorExclude @('public/*') -FileMonitorShowFiles
Set-PodeConfiguration -TransferEncodingDefault 'gzip' -TransferEncodingRoutes @{'/api/*' = 'gzip'; '/status/*' = 'deflate'}
Set-PodeConfiguration -ErrorPagesShowExceptions -ErrorPagesStrictContentTyping
Set-PodeConfiguration -StaticDefaults @('home.html') -StaticCacheEnable -StaticCacheExclude @('*.exe') -StaticCacheInclude @('/images/*', '/assets/*.js')
Set-PodeConfiguration -DefaultFoldersPublic 'c:\custom\public' -DefaultFoldersViews 'd:\shared\views' -DefaultFoldersErrors 'e:\logs\errors'
Set-PodeConfiguration -LoggingMaskingPatterns @('(?<keep_before>Password=)\w+') -LoggingMask '--MASKED--' -LoggingQueueLimit 500

Get-PodeConfiguration

This function retrieves the current configurations for the Pode server by reading from the $PodeContext hashtable.

Parameters

Section: Specifies which section of the configuration to retrieve (e.g., SslProtocols, RequestTimeout, AutoImport, etc.).

Get-PodeConfiguration -Section 'SslProtocols'
Get-PodeConfiguration -Section 'RequestTimeout'
Get-PodeConfiguration