settings¶
Application settings
Project Settings.
- pydantic settings src.server.lib.settings.APISettings[source]¶
Bases:
BaseSettings
API specific configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "APISettings", "description": "API specific configuration.", "type": "object", "properties": { "HEALTH_PATH": { "default": "/health", "title": "Health Path", "type": "string" }, "OPENCOLLECTIVE_KEY": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Opencollective Key" }, "OPENCOLLECTIVE_URL": { "default": "https://api.opencollective.com/graphql/v2", "title": "Opencollective Url", "type": "string" }, "POLAR_KEY": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Polar Key" }, "POLAR_URL": { "default": "https://api.polar.sh", "title": "Polar Url", "type": "string" } } }
- Config:
extra: str = ignore
case_sensitive: bool = True
env_prefix: str = API_
env_file: str = .env
- Fields:
- field OPENCOLLECTIVE_URL: str = 'https://api.opencollective.com/graphql/v2'¶
OpenCollective API URL.
Note
This is the GraphQL endpoint, the REST endpoint is no longer maintained. See also: OpenCollective API Docs
- field POLAR_URL: str = 'https://api.polar.sh'¶
Polar API URL.
See also
Polar API Docs and the Public API #834 Issue.
- pydantic settings src.server.lib.settings.DatabaseSettings[source]¶
Bases:
BaseSettings
Configures the database for the application.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "DatabaseSettings", "description": "Configures the database for the application.", "type": "object", "properties": { "ECHO": { "default": false, "title": "Echo", "type": "boolean" }, "ECHO_POOL": { "anyOf": [ { "type": "boolean" }, { "const": "debug" } ], "default": false, "title": "Echo Pool" }, "POOL_DISABLE": { "default": true, "title": "Pool Disable", "type": "boolean" }, "POOL_MAX_OVERFLOW": { "default": 10, "title": "Pool Max Overflow", "type": "integer" }, "POOL_SIZE": { "default": 5, "title": "Pool Size", "type": "integer" }, "POOL_TIMEOUT": { "default": 30, "title": "Pool Timeout", "type": "integer" }, "POOL_RECYCLE": { "default": 300, "title": "Pool Recycle", "type": "integer" }, "POOL_PRE_PING": { "default": false, "title": "Pool Pre Ping", "type": "boolean" }, "CONNECT_ARGS": { "default": {}, "title": "Connect Args", "type": "object" }, "URL": { "default": "postgresql+asyncpg://byte:bot@localhost:5432/byte", "title": "Url", "type": "string" }, "ENGINE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Engine" }, "USER": { "default": "byte", "title": "User", "type": "string" }, "PASSWORD": { "default": "bot", "title": "Password", "type": "string" }, "HOST": { "default": "localhost", "title": "Host", "type": "string" }, "PORT": { "default": 5432, "title": "Port", "type": "integer" }, "NAME": { "default": "byte", "title": "Name", "type": "string" }, "MIGRATION_CONFIG": { "default": "/home/runner/work/byte/byte/src/server/lib/db/alembic.ini", "title": "Migration Config", "type": "string" }, "MIGRATION_PATH": { "default": "/home/runner/work/byte/byte/src/server/lib/db/migrations", "title": "Migration Path", "type": "string" }, "MIGRATION_DDL_VERSION_TABLE": { "default": "ddl_version", "title": "Migration Ddl Version Table", "type": "string" } } }
- Config:
extra: str = ignore
env_prefix: str = DB_
env_file: str = .env
env_file_encoding: str = utf-8
- Fields:
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- field POOL_MAX_OVERFLOW: int = 10¶
See
QueuePool
.Warning
This is arguably pretty high, and shouldn’t be raised past 10.
- field MIGRATION_CONFIG: str = '/home/runner/work/byte/byte/src/server/lib/db/alembic.ini'¶
Path to Alembic config file.
- pydantic settings src.server.lib.settings.GitHubSettings[source]¶
Bases:
BaseSettings
Configures GitHub app for the project.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "GitHubSettings", "description": "Configures GitHub app for the project.", "type": "object", "properties": { "NAME": { "default": "byte-bot-app", "title": "Name", "type": "string" }, "APP_ID": { "default": 480575, "title": "App Id", "type": "integer" }, "APP_PRIVATE_KEY": { "default": "", "title": "App Private Key", "type": "string" }, "APP_CLIENT_ID": { "default": "Iv1.c3a5214c6642dedd", "title": "App Client Id", "type": "string" }, "APP_CLIENT_SECRET": { "default": "", "title": "App Client Secret", "type": "string" }, "REDIRECT_URL": { "default": "http://127.0.0.1:3000/github/session", "title": "Redirect Url", "type": "string" }, "PERSONAL_ACCESS_TOKEN": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Personal Access Token" } } }
- Config:
extra: str = ignore
case_sensitive: bool = True
env_prefix: str = GITHUB_
env_file: str = .env
- Fields:
- Validators:
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- validator validate_and_load_private_key » APP_PRIVATE_KEY[source]¶
Validates and loads the GitHub App private key.
- Parameters:
value – The value of the APP_PRIVATE_KEY setting.
- Returns:
The validated and loaded GitHub App private key.
- pydantic settings src.server.lib.settings.LogSettings[source]¶
Bases:
BaseSettings
Logging config for the Project.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "LogSettings", "description": "Logging config for the Project.", "type": "object", "properties": { "EXCLUDE_PATHS": { "default": "\\A(?!x)x", "title": "Exclude Paths", "type": "string" }, "HTTP_EVENT": { "default": "HTTP", "title": "Http Event", "type": "string" }, "INCLUDE_COMPRESSED_BODY": { "default": false, "title": "Include Compressed Body", "type": "boolean" }, "LEVEL": { "default": 20, "title": "Level", "type": "integer" }, "OBFUSCATE_COOKIES": { "default": [ "session" ], "items": { "type": "string" }, "title": "Obfuscate Cookies", "type": "array", "uniqueItems": true }, "OBFUSCATE_HEADERS": { "default": [ "X-API-KEY", "Authorization" ], "items": { "type": "string" }, "title": "Obfuscate Headers", "type": "array", "uniqueItems": true }, "JOB_FIELDS": { "default": [ "function", "kwargs", "key", "scheduled", "attempts", "completed", "queued", "started", "result", "error" ], "items": { "type": "string" }, "title": "Job Fields", "type": "array" }, "REQUEST_FIELDS": { "default": [ "path", "method", "headers", "cookies", "query", "path_params", "body" ], "items": { "enum": [ "path", "method", "content_type", "headers", "cookies", "query", "path_params", "body", "scheme", "client" ], "type": "string" }, "title": "Request Fields", "type": "array" }, "RESPONSE_FIELDS": { "default": [ "status_code", "cookies", "headers" ], "items": { "enum": [ "status_code", "headers", "body", "cookies" ], "type": "string" }, "title": "Response Fields", "type": "array" }, "UVICORN_ACCESS_LEVEL": { "default": 30, "title": "Uvicorn Access Level", "type": "integer" }, "UVICORN_ERROR_LEVEL": { "default": 20, "title": "Uvicorn Error Level", "type": "integer" } } }
- Config:
extra: str = ignore
case_sensitive: bool = True
env_prefix: str = LOG_
env_file: str = .env
- Fields:
- field OBFUSCATE_HEADERS: set[str] = {'Authorization', 'X-API-KEY'}¶
Request header keys to obfuscate.
- field JOB_FIELDS: list[str] = ['function', 'kwargs', 'key', 'scheduled', 'attempts', 'completed', 'queued', 'started', 'result', 'error']¶
Attributes of the SAQ
Job
to be logged.
- field REQUEST_FIELDS: list[RequestExtractorField] = ['path', 'method', 'headers', 'cookies', 'query', 'path_params', 'body']¶
Attributes of the
Request
to be logged.
- pydantic settings src.server.lib.settings.OpenAPISettings[source]¶
Bases:
BaseSettings
Configures OpenAPI for the Project.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "OpenAPISettings", "description": "Configures OpenAPI for the Project.", "type": "object", "properties": { "CONTACT_NAME": { "default": "Admin", "title": "Contact Name", "type": "string" }, "CONTACT_EMAIL": { "default": "hello@byte-bot.app", "title": "Contact Email", "type": "string" }, "TITLE": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "Byte Bot", "title": "Title" }, "VERSION": { "default": "0.2.0", "title": "Version", "type": "string" }, "PATH": { "default": "/api", "title": "Path", "type": "string" }, "DESCRIPTION": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "The Byte Bot API supports the Byte Discord bot.\n You can find out more about this project in the\n [docs](https://docs.byte-bot.app/latest).", "title": "Description" }, "SERVERS": { "default": [], "items": { "additionalProperties": { "type": "string" }, "type": "object" }, "title": "Servers", "type": "array" }, "EXTERNAL_DOCS": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": { "description": "Byte Bot API Docs", "url": "https://docs.byte-bot.app/latest" }, "title": "External Docs" } } }
- Config:
extra: str = ignore
case_sensitive: bool = True
env_prefix: str = OPENAPI_
env_file: str = .env
- Fields:
- Validators:
- field DESCRIPTION: str | None = 'The Byte Bot API supports the Byte Discord bot.\n You can find out more about this project in the\n [docs](https://docs.byte-bot.app/latest).'¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- field SERVERS: list[dict[str, str]] = []¶
Servers to use for the OpenAPI documentation.
- Validated by:
- pydantic settings src.server.lib.settings.ProjectSettings[source]¶
Bases:
BaseSettings
Project Settings.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "ProjectSettings", "description": "Project Settings.", "type": "object", "properties": { "BUILD_NUMBER": { "default": "", "title": "Build Number", "type": "string" }, "CHECK_DB_READY": { "default": true, "title": "Check Db Ready", "type": "boolean" }, "CHECK_REDIS_READY": { "default": true, "title": "Check Redis Ready", "type": "boolean" }, "DEBUG": { "default": false, "title": "Debug", "type": "boolean" }, "ENVIRONMENT": { "default": "prod", "title": "Environment", "type": "string" }, "TEST_ENVIRONMENT_NAME": { "default": "test", "title": "Test Environment Name", "type": "string" }, "LOCAL_ENVIRONMENT_NAME": { "default": "local", "title": "Local Environment Name", "type": "string" }, "NAME": { "default": "Byte Bot", "title": "Name", "type": "string" }, "SECRET_KEY": { "format": "password", "title": "Secret Key", "type": "string", "writeOnly": true }, "JWT_ENCRYPTION_ALGORITHM": { "default": "HS256", "title": "Jwt Encryption Algorithm", "type": "string" }, "BACKEND_CORS_ORIGINS": { "default": [ "*" ], "items": { "type": "string" }, "title": "Backend Cors Origins", "type": "array" }, "STATIC_URL": { "default": "/static/", "title": "Static Url", "type": "string" }, "CSRF_COOKIE_NAME": { "default": "csrftoken", "title": "Csrf Cookie Name", "type": "string" }, "CSRF_COOKIE_SECURE": { "default": false, "title": "Csrf Cookie Secure", "type": "boolean" }, "STATIC_DIR": { "default": "/home/runner/work/byte/byte/src/server/domain/web/resources", "format": "path", "title": "Static Dir", "type": "string" }, "DEV_MODE": { "default": false, "title": "Dev Mode", "type": "boolean" } }, "required": [ "SECRET_KEY" ] }
- Config:
extra: str = ignore
case_sensitive: bool = True
env_file: str = .env
- Fields:
- Validators:
- field TEST_ENVIRONMENT_NAME: str = 'test'¶
Value of ENVIRONMENT used to determine if running tests.
This should be the value of
ENVIRONMENT
intests.env
.
- field LOCAL_ENVIRONMENT_NAME: str = 'local'¶
Value of ENVIRONMENT used to determine if running in local development mode.
This should be the value of
ENVIRONMENT
in your local.env
file.
- field SECRET_KEY: SecretBytes [Required]¶
Secret key used for signing cookies and other things.
- Validated by:
- field BACKEND_CORS_ORIGINS: list[str] = ['*']¶
List of origins allowed to access the API.
- Validated by:
- field STATIC_DIR: Path = PosixPath('/home/runner/work/byte/byte/src/server/domain/web/resources')¶
Path to static assets.
- property slug: str¶
Return a slugified name.
- Returns:
self.NAME
, all lowercase and hyphens instead of spaces.
- validator assemble_cors_origins » BACKEND_CORS_ORIGINS[source]¶
Parse a list of origins.
- Parameters:
value – A comma-separated string of origins, or a list of origins.
- Returns:
A list of origins.
- Raises:
ValueError – If
value
is not a list or string.
- validator generate_secret_key » SECRET_KEY[source]¶
Generate a secret key.
- Parameters:
value – A secret key, or
None
.- Returns:
A secret key.
- pydantic settings src.server.lib.settings.ServerSettings[source]¶
Bases:
BaseSettings
Server configurations.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "ServerSettings", "description": "Server configurations.", "type": "object", "properties": { "APP_LOC": { "default": "src.app:create_app", "title": "App Loc", "type": "string" }, "APP_LOC_IS_FACTORY": { "default": true, "title": "App Loc Is Factory", "type": "boolean" }, "HOST": { "default": "localhost", "title": "Host", "type": "string" }, "KEEPALIVE": { "default": 65, "title": "Keepalive", "type": "integer" }, "PORT": { "default": 8000, "title": "Port", "type": "integer" }, "RELOAD": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Reload" }, "RELOAD_DIRS": { "default": [ "/home/runner/work/byte/byte/src" ], "items": { "type": "string" }, "title": "Reload Dirs", "type": "array" }, "HTTP_WORKERS": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Http Workers" } } }
- Config:
extra: str = ignore
case_sensitive: bool = True
env_prefix: str = SERVER_
env_file: str = .env
- Fields:
- pydantic settings src.server.lib.settings.TemplateSettings[source]¶
Bases:
BaseSettings
Configures Templating for the project.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{ "title": "TemplateSettings", "description": "Configures Templating for the project.", "type": "object", "properties": { "ENGINE": { "title": "Engine" } } }
- Config:
extra: str = ignore
case_sensitive: bool = True
env_prefix: str = TEMPLATE_
env_file: str = .env
- Fields:
- src.server.lib.settings.load_settings() tuple[ProjectSettings, APISettings, OpenAPISettings, TemplateSettings, ServerSettings, LogSettings, DatabaseSettings, GitHubSettings] [source]¶
Load Settings file.
- Returns:
application settings
- Return type:
Settings