Skip to main content

Configuring Functions

When creating a function, a photoniq.toml file is created in your project directory. This file allows you to customize the behavior of your functions by configuring settings such as CORS, logging, metadata, resource limits, and environment variables.

The following table provides a detailed explanation of the fields available in the photoniq.toml file for configuring Rust, JavaScript and Next.js functions:

photoniq.toml
name = "TheFunctionName"
version = "0.0.1"
description = "A description for your function"
lang = "rust"
#execute_url_suffix = "optional_url_suffix_to_execute_function"

[cors_settings]
allowed_methods = ["GET","POST"]
allowed_hosts = ["petstore.swagger.io"]
allow_http = true

[log_settings]
enabled = true
level = "INFO"

[env_vars]
MESSAGE = "Hello 👋! This message comes from an environment variable"

The table below describes the configuration options in the the photoniq.toml:

FieldDescription
nameThe name of the function.
versionThe version of the function.
descriptionA brief description of the function.
langThe programming language used for the function, in this case, rust or js.
execute_url_suffixCustomizes the function execution endpoint. For example, setting execute_url_suffix = "/my/path/suffix" allows the function to be executed via /my/path/suffix/myFunction instead of the default /api/faas/v1/execute/myFunction, like an alias.
[cors_settings]Configuration settings for Cross-Origin Resource Sharing (CORS).
cors_settings.allowed_methodsHTTP methods allowed for CORS.
cors_settings.allowed_hostsHosts allowed to access the function.
cors_settings.allow_httpBoolean indicating if HTTP is allowed.
[log_settings]Configuration settings for logging.
log_settings.enabledBoolean indicating if logging is enabled.
log_settings.levelRefer to Log levels.
[env_vars]Set environment variables required by the function.
env_vars.MESSAGEAn environment variable containing a message.

Log levels​

The log_settings.level defines the granularity of the logs that will be displayed. The following log levels are available, in order of priority from the most restrictive to the most permissive:

  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE

The log level you select determines what messages will be shown. If you set the log level to INFO, only messages with levels INFO, WARN, and ERROR will be displayed. Messages with DEBUG or TRACE will be ignored, even if they exist in the code.