Skip to content

What is the reason of env folder? #105

Open
@alimoli

Description

@alimoli

Feature Request

I am trying to understand what is the purpose of having an /env folder that emulates the configuration already present in Strapi.
Example of config/database.ts:

postgres: {
      connection: {
        connectionString: env('DATABASE_URL'),
        host: env('DATABASE_HOST', 'localhost'),
        port: env.int('DATABASE_PORT', 5432),
        database: env('DATABASE_NAME', 'strapi'),
        user: env('DATABASE_USERNAME', 'strapi'),
        password: env('DATABASE_PASSWORD', 'strapi'),
        ssl: env.bool('DATABASE_SSL', false) && {
          key: env('DATABASE_SSL_KEY', undefined),
          cert: env('DATABASE_SSL_CERT', undefined),
          ca: env('DATABASE_SSL_CA', undefined),
          capath: env('DATABASE_SSL_CAPATH', undefined),
          cipher: env('DATABASE_SSL_CIPHER', undefined),
          rejectUnauthorized: env.bool(
            'DATABASE_SSL_REJECT_UNAUTHORIZED',
            true
          ),
        },
        schema: env('DATABASE_SCHEMA', 'public'),
      },
      pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
    },

My env/database.ts:

export default ({env}) => ({
  connection: {
    client: 'postgres',
    connection: {
      host: env('DATABASE_HOST', undefined),
      port: env.int('DATABASE_PORT', undefined),
      database: env('DATABASE_NAME', undefined),
      user: env('DATABASE_USERNAME', undefined),
      password: env('DATABASE_PASSWORD', undefined),
      ssl: env.bool('DATABASE_SSL', false) && {
        rejectUnauthorized: false
      }
    }
  }
});

Another related question, how does it behave this plugin in case of plugins (f.e. cloudinary)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions