appConfig (config/app.config.ts)

llm-gateway · packages/backend/src/config/app.config.ts · typescript · MIT
email

Module exposing: appConfig, resolveDatabaseUrl

// Source: https://github.com/mnfst/llm-gateway | License: MIT | Copyright 2026 MNFST, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { registerAs } from '@nestjs/config';
import { optionalPositiveInteger } from './env.util';

function resolveDatabaseUrl(): string {
  const url = process.env['DATABASE_URL'];
  if (url) return url;
  if (process.env['NODE_ENV'] === 'test')
    return 'postgresql://myuser:mypassword@localhost:5432/mydatabase';
  throw new Error('DATABASE_URL is required. Set it in your .env file.');
}

export const appConfig = registerAs('app', () => ({
  port: Number(process.env['PORT'] ?? 3001),
  nodeEnv: process.env['NODE_ENV'] ?? 'development',
  databaseUrl: resolveDatabaseUrl(),

  corsOrigin: process.env['CORS_ORIGIN'] ?? 'http://localhos

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key