setConfig()
Signature
Section titled “Signature”app.setConfig(options)Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
port | number | 3000 | Server port |
cors | boolean | Object | false | Enable CORS |
helmet | boolean | Object | false | Security headers |
logs | boolean | string | false | Morgan logging |
bodyParser | boolean | true | JSON + urlencoded |
static | string | boolean | false | Static files path |
views | Object | — | View engine config |
gracefulShutdown | boolean | Object | true | Shutdown handling |
Examples
Section titled “Examples”// Basicapp.setConfig({ port: 8080, logs: "dev", static: "public" });
// Securityapp.setConfig({ cors: { origin: "https://example.com" }, helmet: true});
// View engineapp.setConfig({ views: { engine: "ejs", path: "./views" }});
// Toggle features offapp.setConfig({ logs: false });
// Graceful shutdown with custom timeoutapp.setConfig({ gracefulShutdown: { timeout: 15000, signals: ["SIGTERM"] },});