Express Sweet API Reference - v3.0.0
    Preparing search index...

    Class Environment

    Mount environment variables from .env file. Reads the environment variable file specified in config and sets variables in process.env. Prevents multiple loading with a global flag.

    // Environment variables configuration in config/config.js
    export default {
    env_path: '.env' // Path to environment file
    };
    // .env file contents
    NODE_ENV=development
    DATABASE_URL=mysql://localhost/mydb
    SECRET_KEY=mysecret
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Mount environment variables on application. Loads .env file and sets variables in process.env if not already loaded.

      Returns Promise<void>

      // This method is called automatically by express-sweet.mount()
      import Environment from './middlewares/Environment';

      await Environment.mount();