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

    Function envLoader

    Environment variables loading middleware

    • Mount environment variables on application.

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

      Returns Promise<void>

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

      await envLoader();
      // Environment variables configuration in config/config.js
      export default {
      /**
      * Path to environment file, defaults to undefined.
      * @type {string|undefined}
      */
      env_path: '.env'
      };
      // .env file contents
      NODE_ENV=development
      DATABASE_URL=mysql://localhost/mydb
      SECRET_KEY=mysecret