Options
node-zugferd configuration options reference.
List of all the available options for configuring node-zugferd. See node-zugferd Options.
profiles
List of node-zugferd profiles.
import { zugferd } from "node-zugferd";
import { en16931 } from "@node-zugferd/en-16931";
const invoicer = zugferd({
profiles: [
en16931(),
],
// ...
});plugins
List of node-zugferd plugins.
import { zugferd } from "node-zugferd";
import { xsd } from "@node-zugferd/validator-xsd";
const invoicer = zugferd({
plugins: [
xsd(),
],
// ...
});prettyPrint
Whether to pretty print the XML output. Defaults to false.
import { zugferd } from "node-zugferd";
export const invoicer = zugferd({
prettyPrint: true,
// ...
});logger
Logger configuration for node-zugferd.
import { zugferd } from "node-zugferd";
export const invoicer = zugferd({
logger: {
disabled: false,
level: "warn",
log: (level, message, ...args) => {
// Custom logging implementation
console.log(`[${level}] ${message}`, ...args);
},
},
// ...
});The logger configuration allows you to customize how node-zugferd handles logging. It supports the following options:
-
Disable all logging when set todisabledtrue(default:false) -
Set the minimum log level to display (default:level"warn")"debug": Show all logs including debug information"info": Show all logs except debug information"warn": Show warnings and errors"error": Show only errors
-
Custom logging function that receives:loglevel: The log levelmessage: The log message...args: Additional arguments to the logger
Example with custom logging:
import { zugferd } from "node-zugferd";
export const invoicer = zugferd({
logger: {
level: "info",
log: (level, message, ...args) => {
// Send logs to a custom logging service
myLoggingService.log({
level,
message,
metadata: args,
timestamp: new Date().toISOString()
});
},
},
// ...
});hooks
Invoice lifecycle hooks.
Called after the XML document has been built.
import { zugferd } from "node-zugferd";
export const invoicer = zugferd({
hooks: {
afterXMLBuild: ({ xml, profile, context }) => {
// Custom logic to execute after XML is built
validate(profile.id, xml);
},
},
// ...
});advanced
Advanced configuration options.
import { zugferd } from "node-zugferd";
export const invoicer = zugferd({
advanced: {
// ...
},
});instrumentation
Instrumentation configuration.
import { zugferd } from "node-zugferd";
export const invoicer = zugferd({
advanced: {
instrumentation: {
// ...
},
},
});The instrumentation configuration allows you to customize the span implementation. It supports the following options:
-
Custom span implementation that receives:spanname: The span nameattr: The span attributesfn: The span function
import { zugferd } from "node-zugferd";
export const invoicer = zugferd({
advanced: {
instrumentation: {
span: async (name, attr, fn) => {
const result = await fn();
console.log(`Span ${name} completed with result:`, result);
return result;
}
},
},
// ...
});