Skip to content

Configuration

The Shokupan class accepts a configuration object to customize behavior.

const app = new Shokupan({
port: 3000,
hostname: 'localhost',
development: process.env.NODE_ENV !== 'production'
});
OptionTypeDefaultDescription
portnumber3000The port the server should listen on.
hostnamestring'localhost'The hostname to bind to.
reusePortbooleanfalseAllow multiple processes to bind to the same port.
serverFactoryServerFactoryBun.serveCustom server factory (e.g., for Node.js support).
tls{ key: string, cert: string }undefinedCustom TLS configuration for HTTPS. If omitted in dev mode, local certs are autogenerated.
OptionTypeDefaultDescription
developmentbooleanautoEnable development mode (affects error pages, etc.).
enableAsyncLocalStoragebooleanfalseEnable AsyncLocalStorage for request-scoped globals.
controllersOnlybooleanfalseIf true, disables app.get(), app.post() etc., enforcing controller-only architecture.
OptionTypeDefaultDescription
enableTracingbooleanfalseEnable OpenTelemetry tracing integration.
enableOpenApiGenbooleantrueEnable automatic OpenAPI specification generation.
enableMiddlewareTrackingbooleanfalseTrack middleware execution for debugging (required for Debug Dashboard).

When development is enabled (which happens automatically if NODE_ENV !== "production"), Shokupan drastically enhances your developer experience by injecting defaults:

  • Local HTTPS: Autogenerates an SSL Root CA and trusts it in your OS to serve your API cleanly over https://localhost:3000.
  • Debug Dashboard: Automatically mounts at /dashboard and enables enableMiddlewareTracking.
  • API Explorer: Automatically mounts at /dashboard/explorer.
  • AsyncAPI Explorer: Automatically mounts at /dashboard/ws-explorer.
  • ErrorView: Automatically mounts to provide beautiful HTML stack traces on uncaught exceptions.

You can override TLS auto-generation by providing your own certificates in the tls config block.

OptionTypeDefaultDescription
readTimeoutnumber30000Timeout for reading the request body (ms).
requestTimeoutnumber0 (disabled)Global timeout for processing requests (ms).

Protect your server from overload by shedding load when CPU usage is high.

OptionTypeDefaultDescription
autoBackpressureFeedbackbooleanfalseEnable automatic load shedding.
autoBackpressureLevelnumber60CPU usage % threshold to start rejecting requests with 503.