Configuration
Platformatic Service configured with a configuration file. It supports the use of environment variables as setting values with configuration placeholders.
Configuration Files
The Platformatic CLI automatically detects and loads configuration files found in the current working directory with the file names listed here.
Alternatively, you can specify a configuration file path using the --config
option for most platformatic runtime
CLI commands. The configuration examples in this reference use the JSON format.
Supported File Formats
For detailed information on supported file formats and extensions, please visit our Supported File Formats and Extensions page.
Settings
Configuration settings containing sensitive data, such as database connection URLs and passwords, should be set using configuration placeholders.
basePath
Service proxy base path when exposing this service in a composer when setting the proxy
property.
If not specified, the service will be exposed on the service or a value specified in the service code via platformatic.setBasePath()
.
server
An object with the following settings:
-
hostname
— Hostname where Platformatic Service server will listen for connections. -
port
— Port where Platformatic Service server will listen for connections. -
healthCheck
(boolean
orobject
) — Enables the health check endpoint.- Powered by
@fastify/under-pressure
. - The value can be an object, used to specify the interval between checks in milliseconds (default:
5000
)
Example
{
"server": {
...
"healthCheck": {
"interval": 2000
}
}
} - Powered by
-
cors
(object
) — Configuration for Cross-Origin Resource Sharing (CORS) headers.- All options will be passed to the
@fastify/cors
plugin. In order to specify aRegExp
object, you can pass{ regexp: 'yourregexp' }
, it will be automatically converted
- All options will be passed to the
-
http2
(boolean
) — Enables HTTP/2 support. Default:false
. -
https
(object
) - Configuration for HTTPS supporting the following options. Requireshttps
.allowHTTP1
(boolean
) - Iftrue
, the server will also accept HTTP/1.1 connections whenhttp2
is enabled. Default:false
.key
(required,string
,object
, orarray
) - Ifkey
is a string, it specifies the private key to be used. Ifkey
is an object, it must have apath
property specifying the private key file. Multiple keys are supported by passing an array of keys.cert
(required,string
,object
, orarray
) - Ifcert
is a string, it specifies the certificate to be used. Ifcert
is an object, it must have apath
property specifying the certificate file. Multiple certificates are supported by passing an array of keys.
-
logger
(object
) -- the logger configuration. -
pluginTimeout
(integer
) -- the number of milliseconds to wait for a Fastify plugin to load -
bodyLimit
(integer
) -- the maximum request body size in bytes -
maxParamLength
(integer
) -- the maximum length of a request parameter -
caseSensitive
(boolean
) -- iftrue
, the router will be case-sensitive -
ignoreTrailingSlash
(boolean
) -- iftrue
, the router will ignore the trailing slash -
connectionTimeout
(integer
) -- the milliseconds to wait for a new HTTP request -
keepAliveTimeout
(integer
) -- the milliseconds to wait for a keep-alive HTTP request -
maxRequestsPerSocket
(integer
) -- the maximum number of requests per socket -
forceCloseConnections
(boolean
or"idle"
) -- iftrue
, the server will close all connections when it is closed -
requestTimeout
(integer
) -- the milliseconds to wait for a request to be completed -
disableRequestLogging
(boolean
) -- iftrue
, the request logger will be disabled -
exposeHeadRoutes
(boolean
) -- iftrue
, the router will expose HEAD routes -
serializerOpts
(object
) -- the serializer options -
requestIdHeader
(string
orfalse
) -- the name of the header that will contain the request id -
requestIdLogLabel
(string
) -- Defines the label used for the request identifier when logging the request. default:'reqId'
-
jsonShorthand
(boolean
) -- default:true
-- visit fastify docs for more details -
trustProxy
(boolean
orinteger
orstring
orString[]
) -- default:false
-- visit fastify docs for more details
See the fastify docs for more details.
metrics
Configuration for a Prometheus server that will export monitoring metrics
for the current server instance. It uses fastify-metrics
under the hood.
This setting can be a boolean
or an object
. If set to true
the Prometheus server will listen on http://0.0.0.0:9090
.
Supported object properties:
server
(enum
) — Can be set to "own", "parent" or "hide" to determine if metrics will be served on a different server, the same server as the Platformatic application, or hidden entirely.hostname
(string
, default:0.0.0.0
) — The hostname where the Prometheus server will listen for connections. This should be used only ifserver
is set to "own".port
(number
orstring
, default:9090
) — The port where the Prometheus server will listen for connections. This should be used only ifserver
is set to "own".endpoint
(string
, default:/metrics
) — The endpoint on which metrics will be served.auth
(object
) — Basic Auth configuration.username
andpassword
are required here (use environment variables).labels
(object
) —{ key : value }
Map of labels that are applied to metrics.readiness
(object
orboolean
, default:true
) — Configuration for readiness checks. If set totrue
, default readiness checks are enabled. If an object is provided, it can include:endpoint
(string
, default:/ready
) — The endpoint for readiness checks.success
(object
) — Defines the success criteria for readiness checks.statusCode
(number
, default:200
) — The HTTP status code indicating success.body
(string
, default:OK
) — The response body indicating success.
fail
(object
) — Defines the failure criteria for readiness checks.statusCode
(number
, default:500
) — The HTTP status code indicating failure.body
(string
, default:ERR
) — The response body indicating failure.
liveness
(object
orboolean
, default:true
) — Configuration for liveness checks. If set totrue
, default liveness checks are enabled. If an object is provided, it can include:endpoint
(string
, default:/status
) — The endpoint for liveness checks.success
(object
) — Defines the success criteria for liveness checks.statusCode
(number
, default:200
) — The HTTP status code indicating success.body
(string
, default:OK
) — The response body indicating success.
fail
(object
) — Defines the failure criteria for liveness checks.statusCode
(number
, default:500
) — The HTTP status code indicating failure.body
(string
, default:ERR
) — The response body indicating failure.