Skip to content

Environment & Config

Kaelum automatically loads variables from a .env file in your project root using dotenv. No need to manually require('dotenv').config().

.env
PORT=4000
DB_URL=mongodb://localhost/mydb
API_KEY=your-secret-key

Access them via process.env:

const port = process.env.PORT || 3000;
app.start(port);

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"
}
});
OptionTypeDefaultDescription
portnumber3000Port for app.start()
corsboolean | ObjectfalseEnable CORS
helmetboolean | ObjectfalseEnable Helmet headers
logsboolean | stringfalseEnable morgan logging
bodyParserbooleantrueJSON + URL-encoded parsing
staticstring | booleanfalseStatic files directory
viewsObjectView engine ({ engine, path })