Overview
ThecreateConfig() function creates a configuration object that controls the behavior of your Express Zod API server. It accepts a configuration object and returns a validated config ready for use with createServer() or attachRouting().
Signature
Configuration Options
The configuration object accepts options from three categories:Common Options
CORS, logging, error handling, input sources
Server Options
HTTP/HTTPS server configuration
App Options
Attach to existing Express app
Common Options
These options are available in all configurations:Enable CORS and optionally customize headers
Built-in logger configuration or custom logger instance
Custom result handler for routing and parsing errorsDefault:
defaultResultHandlerCustomize which request properties are merged into
inputCreate a child logger for each request with custom context
Custom access logging function or
null to disableHow to respond when wrong HTTP method is used
404: Not Found405: Method Not Allowed (includes Allow header)
405How to treat routing keys that look like HTTP methodsDefault:
"method"Show the Express Zod API logo on startupDefault:
trueServer Options
Use these options when creating a standalone server:HTTP server configuration
HTTPS server configuration with TLS certificates
Graceful shutdown configuration
Configure Express app before routing is attached
Custom JSON body parser or
false to disableDefault: express.json()Custom URL-encoded form parser or
false to disableDefault: express.urlencoded({ extended: false })Enable file uploads with optional configuration
Enable GZIP/Brotli compression
Query string parser
"simple": Node’s querystring module"extended": qs module with nested objects- Custom function:
(str) => qs.parse(str, { comma: true })
"simple"App Options
Use when attaching to an existing Express application:Express application or router instance
Examples
Minimal Configuration
Production Configuration
With Existing Express App
See Also
Config Options
Detailed reference for all configuration options
createServer
Start a server with your configuration
Production Mode
Production deployment best practices
CORS
Configure cross-origin resource sharing