Pode
Pode copied to clipboard
Pode Configuration Functions (idea not ready yet)
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
- SslProtocols: Sets SSL protocols.
- RequestTimeout: Defines the request timeout in seconds.
- RequestBodySize: Defines the maximum body size for a request in bytes.
- DisableAutoImportModules: Disables the AutoImport setting for Modules.
- AutoImportModulesExportOnly: Sets the AutoImport Modules ExportOnly option.
- DisableAutoImportSnapins: Disables the AutoImport setting for Snapins.
- AutoImportSnapinsExportOnly: Sets the AutoImport Snapins ExportOnly option.
- DisableAutoImportFunctions: Disables the AutoImport setting for Functions.
- AutoImportFunctionsExportOnly: Sets the AutoImport Functions ExportOnly option.
- DisableSecretManagement: Disables the AutoImport setting for SecretVault.
- SecretManagementExportOnly: Sets the AutoImport SecretVault ExportOnly option.
- Root: Overrides root path of the server.
- RestartPeriod: Sets the interval in minutes for automatically restarting the server.
- RestartCrons: Sets the cron schedules for automatically restarting the server.
- RestartTimes: Sets the times for automatically restarting the server in the format "HH:mm".
- FileMonitorEnable: Enables or disables file monitoring for restarting the server.
- FileMonitorInclude: Specifies the file patterns to include for monitoring.
- FileMonitorExclude: Specifies the file patterns to exclude from monitoring.
- FileMonitorShowFiles: Enables or disables showing monitored files.
- DefaultFoldersPublic: Sets the custom path for the Public folder.
- DefaultFoldersViews: Sets the custom path for the Views folder.
- DefaultFoldersErrors: Sets the custom path for the Errors folder.
- OpenApiDefaultDefinitionTag: Defines the primary tag name for OpenAPI.
- StaticValidateLast: Changes the way routes are processed.
- TransferEncodingDefault: Sets the default transfer encoding.
- TransferEncodingRoutes: Sets the transfer encoding for specific routes.
- Compression: Sets any compression to use on the Response.
- ContentTypeDefault: Sets the default transfer encoding.
- ContentTypeRoutes: Sets the transfer encoding for specific routes.
- ErrorPagesDefault: Sets the default transfer encoding.
- ErrorPagesRoutes: Sets the transfer encoding for specific routes.
- ErrorPagesShowExceptions: Enables or disables the viewing of exceptions on the error page.
- ErrorPagesStrictContentTyping: Enables or disables generating an error page that matches the route/request's content type.
- StaticDefaults: Sets the default static files.
- StaticCacheEnable: Enables or disables caching for static content.
- StaticCacheExclude: Specifies the file patterns to exclude from caching.
- StaticCacheInclude: Specifies the file patterns to include for caching.
- LoggingMaskingPatterns: Defines the patterns for masking sensitive data in logs.
- LoggingMask: Defines the mask to use for sensitive data in logs.
- LoggingQueueLimit: Defines the maximum number of logs allowed in the queue before throwing an event.
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