Environment & Config
Environment Variables
Section titled “Environment Variables”Kaelum automatically loads variables from a .env file in your project root using dotenv. No need to manually require('dotenv').config().
PORT=4000DB_URL=mongodb://localhost/mydbAPI_KEY=your-secret-keyAccess them via process.env:
const port = process.env.PORT || 3000;app.start(port);setConfig()
Section titled “setConfig()”Centralized configuration for your application:
app.setConfig({ port: 8080, // default port cors: true, // enable CORS helmet: true, // security headers logs: "dev", // morgan logging bodyParser: true, // JSON + urlencoded static: "public", // static files directory views: { // view engine engine: "ejs", path: "./views" }});Options Reference
Section titled “Options Reference”| Option | Type | Default | Description |
|---|---|---|---|
port | number | 3000 | Port for app.start() |
cors | boolean | Object | false | Enable CORS |
helmet | boolean | Object | false | Enable Helmet headers |
logs | boolean | string | false | Enable morgan logging |
bodyParser | boolean | true | JSON + URL-encoded parsing |
static | string | boolean | false | Static files directory |
views | Object | — | View engine ({ engine, path }) |