Environment

Nova automatically detects the current environment via NODE_ENV and provides helper methods through the Environment class.

Accessing the Environment

The environment is available through app.env:

main.ts TypeScript
const app = await NovaFactory.create();

console.log(app.env.name);              // 'development'
console.log(app.env.isDevelopment());   // true
console.log(app.env.isProduction());    // false
console.log(app.env.isTest());          // false

API

Property / MethodReturnsDescription
.name string The raw value of NODE_ENV (defaults to "development").
.isDevelopment() boolean Returns true if NODE_ENV === "development".
.isProduction() boolean Returns true if NODE_ENV === "production".
.isTest() boolean Returns true if NODE_ENV === "test".

Common Patterns

Conditional Configuration TypeScript
const app = await NovaFactory.create({
  logger: !app.env.isTest(),
});

// Enable Swagger only in development
if (app.env.isDevelopment()) {
  await app.openAPI();
  await app.enableDocs();
}

// Stricter rate limiting in production
if (app.env.isProduction()) {
  await app.security(
    Security.rateLimit({ max: 30, timeWindow: '1 minute' })
  );
}