Configuration
Platformatic Node is configured with a configuration file. It supports the use of environment variables as setting values with configuration placeholders.
application
Supported object properties:
basePath
: Service proxy base path when exposing this application in a composer when setting theproxy
property. If not specified, the service will be exposed on the service or a value specified in the service code viaplatformatic.setBasePath()
.outputDirectory
: The subdirectory where production build is stored at when usingwattpm build
orplt build
. The default isdist
.include
: The paths to include when deploying the service. The default is['dist']
.commands
: An object specifying the commands to manage the application instead of directly executing the service entrypoint. Supported commands are:install
: The command to execute to install the service dependencies. The default isnpm ci --omit-dev
.build
: The command to execute to build the application.development
: The command to execute to start the application in development mode.production
: The command to execute to start the application in production mode.
node
Configures Node. Supported object properties:
main
: The entrypoint of the application. This is only needed if themain
property is not set in the servicepackage.json
file.absoluteUrl
: If set totrue
, then the service will receive the full URL from a Platformatic Composer. The default isfalse
.dispatchViaHttp
: If set totrue
, then the service will serve requests coming from the mesh network via a TCP port.disablePlatformaticInBuild
: If set totrue
, then no Platformatic code will be started when running thebuild
command.
logger
Configures the logger, see the logger configuration for more information.
Additionally to the logger configuration, the following properties are supported:
formatters
: specifying the formatters to use for the logger, forbindings
andlevel
, following the pino formatters. The functions must be specified and exported in a separate ESM file and referenced with thepath
property.timestamp
: the timestamp format to use for the logs, one of:isoTime
epochTime
unixTime
nullTime
redact
: specify thepaths
and optionally thecensor
for redactions, see pino redact.
Example:
platformatic.application.json
{
"$schema": "https://schemas.platformatic.dev/@platformatic/node/2.60.0.json",
"logger": {
"formatters": {
"path": "formatters.js",
},
"timestamp": "isoTime",
"redact": {
"censor": "[redacted]",
"paths": ["secret", "req.headers.authorization"]
}
}
}
formatters.js
export function bindings (bindings) {
return { service: 'service-name' }
}
export function level (label) {
return { level: label.toUpperCase() }
}
Alternatively, formatters.bindings
and redact
can be specified deriving from the globalThis.platformatic.logger
object as follows; note that the timestamp
and formatters.level
are not supported in this case.
const app = fastify({
loggerInstance: globalThis.platformatic.logger.child({ service: 'app1' },
{
formatters: {
bindings: (bindings) => {
return { name: bindings.service }
},
},
redact: {
paths: ['secret'],
censor: '***HIDDEN***'
}
})
})
server
Configures the HTTP server, see the runtime documentation.
watch
Manages watching of the service, see the service documentation.
Issues
If you run into a bug or have a suggestion for improvement, please raise an issue on GitHub or join our Discord feedback channel.