Created
March 21, 2021 21:37
-
-
Save kerren/df00e5b8e8bc7544725f3d797b856332 to your computer and use it in GitHub Desktop.
[Config barrel file] The barrel file in the config folder #config #barrel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as path from 'path'; | |
/** | |
* I use app-root-path to determine where the root of the project is. By doing this, I am able | |
* to place this index.ts file anywhere in the project structure. | |
*/ | |
import * as appRootPath from 'app-root-path'; | |
/** | |
* This is an awesome way to read in .env files if you don't always want to load the env in | |
* the container. | |
*/ | |
import * as dotenv from 'dotenv'; | |
const envPath = path.join(appRootPath.path, '.env'); | |
dotenv.config({ path: envPath }); | |
/** | |
* Now we can import the different files that we've set up (this way we can still split the | |
* config up into smaller "features" | |
*/ | |
import { app } from './app'; | |
import { auth } from './auth'; | |
import { database } from './database'; | |
/** | |
* This is OPTIONAL but it allows us to import single features. | |
*/ | |
export * from './app'; | |
export * from './auth'; | |
export * from './database'; | |
/** | |
* Finally, we export an object that makes it easy to import into the rest of the project | |
*/ | |
export const Config = { | |
app, | |
auth, | |
database | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment