Skip to content

Commit

Permalink
feat: add support for multiple .env files. (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
AkhilJ321 authored Jan 16, 2024
1 parent 777dec6 commit 3a7daca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions docs/pages/env-vars-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ Glee provides a few environment variables for you to customize the Glee applicat
|GLEE_SERVER_CERTS|A comma-separated list of `${serverName}:${pathToCertificateFile}`. These are the certificates to use when establishing the connection to the given server.|`GLEE_SERVER_CERTS=mosquitto:mosquitto.org.crt`|
|GLEE_SERVER_VARIABLES|A comma-separated list of `${serverName}:${serverVariable}:${value}`. These are the values to use for each server variable.|`GLEE_SERVER_VARIABLES=websockets:namespace:public`|

### Support for multiple .env files
Glee has support for loading variables from `.env.local` into `process.env`.
This is useful for storing secret environment variables needed in development while keeping them out of the repository.
However, sometimes you might want to add some defaults for the `development` or `production` environment. You can do that by creating files with the following names:
`.env.development` or `.env.production`

`.env.local` always overrides any other existing `.env*` file.

You can change the environment by setting the `NODE_ENV` variable to `development` or `production`.

## Configuring Glee

Glee comes with sensible defaults so you don't have to worry about configuration. However, sometimes you may want to change the behavior or customize Glee in different ways. For that purpose, you can use the `glee.config.js` file.
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@asyncapi/html-template": "^2.0.0",
"@asyncapi/markdown-template": "^1.5.0",
"@asyncapi/parser": "^3.0.2",
"@next/env": "^14.0.4",
"@types/jest": "^29.5.11",
"@types/qs": "^6.9.7",
"ajv": "^6.12.6",
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { resolve } from 'path'
import * as dotenv from 'dotenv'
import dotenvExpand from 'dotenv-expand'
import Glee from './lib/glee.js'
import { logWelcome, logLineWithIcon, logWarningMessage } from './lib/logger.js'
import experimentalFlags from './lib/experimentalFlags.js'
Expand Down Expand Up @@ -33,8 +31,12 @@ import { getSelectedServerNames } from './lib/servers.js'
import { EnrichedEvent, AuthEvent } from './lib/adapter.js'
import { ClusterEvent } from './lib/cluster.js'
import { getMessagesSchema } from './lib/util.js'
import { OperationReplyInterface } from '@asyncapi/parser'
import {loadEnvConfig} from '@next/env'

dotenvExpand(dotenv.config())

const isDev = process.env.NODE_ENV === 'development'
loadEnvConfig(process.cwd(), isDev)

enum LOG_CONFIG {
NONE = 'none',
Expand Down

0 comments on commit 3a7daca

Please sign in to comment.